Skip to content
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

Codify model restrictions and defaults #23

Open
RastislavTuranyi opened this issue Jan 29, 2025 · 1 comment · May be fixed by #32
Open

Codify model restrictions and defaults #23

RastislavTuranyi opened this issue Jan 29, 2025 · 1 comment · May be fixed by #32
Labels
enhancement New feature or request

Comments

@RastislavTuranyi
Copy link
Collaborator

Currently, the restrictions and defaults that any given model requires are completely free-form and undefined - the only requirement are ModelData.restrictions and ModelData.defaults which create a unified interface for users to use. However, the meaning of these is in fact unclear; e.g. is a list of three values for e_init restrictions the three allowed values or the (stop, start, step) tuple?

There is a way to improve all aspects of this by adding to the YAML file spec the fact that restrictions and defaults must be specified as dictionaries, i.e.:

parameters:
    defaults:
        e_init: [100, 1000]
        chopper_frequency: !!set {60, 120, 180}

which can then be used directly without accessing any underlying attributes. Further, as shown above, it can be made a part of the spec that a YAML list is interpreted as a (start, stop, step) tuple, as in range, and a YAML set is interpreted as a list of discrete values.

@RastislavTuranyi RastislavTuranyi added the enhancement New feature or request label Jan 29, 2025
@RastislavTuranyi
Copy link
Collaborator Author

Thinking about implementing this, it may be a good idea to push all of this to the YAML data files wholly by making the defaults and restrictions required for all models, even those who do not use these. This would allow us to get rid of the ModelData.defaults and ModelData.restrictions @property-ies and instead treat them like function and citations - simple attributes. I feel like this would simplify most things (at the cost of some more boilerplate for some models in the YAML files).

On a somewhat related note, I have come to realise that there isn't much good way to identify the settings of a model - the only reliable method is the get_model_signature() method, but that retuns a lot of information and can be a bit complicated for simple queries. The other way I recommend in some of the how-to guides (#15) is to use the aforementioned ModelData.defaults and ModelData.restrictions properties, but there is no guarantee that every setting a model has, also has a default and restriction. Therefore, it might be desirable to add an item to the model YAML data that could carry the names of the settings required by a given model, e.g; settings: ['e_init', 'chopper_frequency']. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant