Skip to content

1.5.1

Choose a tag to compare

@TomGeorge1234 TomGeorge1234 released this 21 Apr 16:39
· 279 commits to dev since this release

1.5.1

Parameter checking

New feature created by @colleenjg which checks parameters passed by the user in the params dict. It works as follows:

If I initialise, for example, some GridCells (a subclass of Neurons) then at the point of initialisation of the parent Neurons class a check is performed: starting from the child class (GridCells) and working upwards to the top-level parent (Neurons) a dictionary of all valid default params -- the super set of GridCells.default_params and Neurons.default_params -- is established. Then, if any of the passed default params is not present in this set a warning is thrown. Example

GCs = GridCells(Ag,{"gridscalee":0.1}) # note typo: "gridscale" --> "gridscalee"  

returns:

UserWarning: Found 1 unexpected params key(s) while initializing Environment object: 'boundary_conditcions'.
If you intended to set this parameter, ignore this message. To see all default parameters for this class call Environment.get_all_default_params().

It this parameter is a new intended by the user then they can ignore the warning. If not it will help prevent silent errors where parameters were incorrectly defined.

In order for this to work default_params now live as a class attribute and are defined in the preamble before __init__()

Users can query the default params of any class, including those inherited from their parents, by runnings:

GridCells.get_all_default_params()