Open gidili opened 5 years ago
Need to have a conversation here to clarify a course of action
For now, let's implement this generically as Test.get_param_units(param_name)
(see #361 for related discussion), which I can then properly implement when the docstrings are complete and settled upon. You can call that, and I will write it into SciUnit as something like:
...
def get_param_units(self, param):
param_info = self.get_param_from_docstring(param)
if 'units' in param_info:
return units
else:
param_info = self.default_params[param_name]
if hasattr(param_info, 'units'):
return param_info.units
And when the docstring works it will use that, and otherwise it will check the default_params
cerberus schema, which at least exists for most NeuronUnit tests.
These units will either be objects from the python quantities package (e.g. pq.pA
), or string representations of the same (e.g. "pq.pA"), TBD. If they are quantities objects you can simply call their rescale method to rescale them back to base units (e.g. amps) if that is what Geppetto will expect. I think they could be stored in the database as their base units as well, but then be rescaled (in reverse) to their human-readable units (e.g. pA) for display on the site using the same logic.
From @rgerkin: The default unit scale is hard to use. For example, when specifying a current amplitude when creating a test, it shows that the unit is "A", whereas pA would be more intuitive so I don't have to scale by 10^12. I'm guessing maybe it comes from here: https://github.com/scidash/sciunit/blob/dev/sciunit/validators.py#L75. Maybe you could use the units here: https://github.com/scidash/neuronunit/blob/dev/neuronunit/tests/base.py#L51 (i.e. in the tests's default_params attribute, if it has one, and if that attribute has a key in it) to determine the units that will be shown and how the units will be fed into the test constructor (so if the page shows "pA" and the user puts in 100, you would feed 100pq.pA into the params kwarg, rather than 100pq.A)