You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the test classes in tests/test_covariance_test.py and tests/test_power_spectrum_test.py differ quite a bit.
tests/test_power_spectrum_test.py uses a private method to set the default parameters. However, @rgutzen pointed out this could be done in the init function of the tow_sample_test abstract class. The default params would then be defined as a dictionary in the child classes, which would be very flexible and easy to understand for developers writing new tests.
Best,
Aitor
The text was updated successfully, but these errors were encountered:
SciUnit allows for parameters to be schematized, e.g. here. This schema is then inherited by all child classes, or can be modified piecewise in those classes. Setting params_schema then allows you to validate the parameters used in any instantiation of those classes, to make sure that all the required parameters are there, of the right type, within certain bounds, etc. That is handled in SciUnit for all tests here, by using a cerberus validator here.
@rgerkin yes, params_schema is exactly what we were looking for. However, it seems that for checking the units of a parameter it is necessary to manually add a corresponding function and dict entry to the ParametersValidator class.
I feel there should be a general method to validate the units of a parameter by trying to rescale it to the unit specified in the schema (for example so that time parameters accept also 'ms' when 's' is specified). Although, looking at the cerberus source code I'm not sure how the Validator methods are actually executed.
@rgutzen I wanted a general method but it is tricky because of the way that cerberus works and also that something simple like isinstance(x, pq.ms) doesn't work. isinstance can determine whether something is a python quantity, but not which quantity it is. Consequently there needs to be a custom validator which actually checks the unit type by doing quantities transformations.
I think it will rescale successfully though. On this line it simplifies the input units and checks for match, and simplifying in python quantities will turn e.g. ms into s so both 1000*ms and 1*s should both pass validation. So I think you need one function for each fundamental unit, but don't need additional ones for each prefix (milli, micro, etc.).
But if you figure out how to just make one general one that can handle all possible quantities, let me know!
I noticed that the test classes in
tests/test_covariance_test.py
andtests/test_power_spectrum_test.py
differ quite a bit.tests/test_power_spectrum_test.py
uses a private method to set the default parameters. However, @rgutzen pointed out this could be done in the init function of the tow_sample_test abstract class. The default params would then be defined as a dictionary in the child classes, which would be very flexible and easy to understand for developers writing new tests.Best,
Aitor
The text was updated successfully, but these errors were encountered: