-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default parameter duplication and separation of "lookups" #637
Comments
The other solution is to remove the internal default from the xarray variable (e.g., The advantage is that calling I think the first solution is better overall, because in the backend we always know the name of the variable we are processing, so we can access the default directly. |
After some thinking, I believe every input parameter SHOULD have a default in |
The reason we have |
Heavily in favor of that. In the national example the only ones missing this are:
Most of these are obligatory for other things, or calculated during runtime... maybe my "all parameters should have defaults" idea is not good? |
Yeah, so some are not optimisation problem parameters (they are either lookups - base_tech, carrier_in/out, etc. - or used in preprocessing - lat/lon). I think it's reasonable to set default: NaN if not otherwise given for those parameters that are not lookups. |
Agreed. Summary of fix:
Sounds good? |
Only when updating a parameter, the initial add of parameters needs to call |
And that also is the issue for the attr -> property suggestion. The |
Wait... if we want to keep the defaults of unused parameters after init, then the best solution is the opposite: |
@brynpickering After considering #642, probably an even better solution is to have all this stuff in the new The only issues will be the lookups. I believe those shold NOT show up in parameters. |
They will and can change on-the-fly. A user can define any number of inputs that are actually lookups. If we explicitly define parameters in math (#642) then we could just say that anything not defined there is effectively a lookup table. |
What happened?
This issue is related to #608 and #619, but its solution is slightly different.
At the moment we have
default
values in three places:model.defaults
(unused, but declared)model._model_data.attrs["defaults"]
model._model_data["some_parameter"].attrs["default"]
This leads to the need to track this in two places, and possibly users setting stuff in the wrong place and being confused on why nothing is happening. My proposed solution:
model.defaults
with a@property
that searches inmodel._model_data
with defined defaults. If not there, users should assume that the default value is 0 /nan
/None
(generally equivalent, at least in terms of math results).model._model_data.attrs["defaults"]
, and ensure that the backend and parsers search for stuff in variable attributes instead (assumingNone
if a default is not set).Since attributes are saved automatically in netCDF files, this should reduce bloat and code on our side.
Let me know what you think!
Which operating systems have you used?
Version
v0.7
Relevant log output
No response
The text was updated successfully, but these errors were encountered: