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 have been writing Property Based Tests for GSW using the Hypothesis framework. I have tried to provide reasonable inputs for these functions, however they can return NaN.
The following ranges were used:
Parameter
Minimum
Maximum
Salinity (g/kg)
0
42
Temperature (C)
-2
40
Ice Temperature (C)
-20
0
Sea Pressure (dbar)
0
11,000
Fractions
0
1
Density (kg/m^3)
1000
1060
Longitude
-360
360
Latitude
-90
90
Conductivity (mS/cm)
0
60
The following functions are affected:
CT_from_rho
SA_from_rho
SP_from_C
SP_from_SK
ice_fraction_to_freeze_seawater
melting_ice_SA_CT_ratio
melting_ice_SA_CT_ratio_poly
melting_ice_into_seawater
melting_seaice_SA_CT_ratio
melting_seaice_SA_CT_ratio_poly
melting_seaice_into_seawater
seaice_fraction_to_freeze_seawater
SA_freezing_from_CT
SA_freezing_from_CT_poly
SA_freezing_from_t
SA_freezing_from_t_poly
pressure_freezing_CT
SA_from_SP_Baltic
SP_from_SA_Baltic
Resources
I used these resources to generate the input ranges. If they are incorrect, please let me know and I can adjust my tests and rerun.
I have added tests to this branch and added Hypothesis as a dependency to requirements-dev.txt. Clone the repo, checkout the branch, install the dependencies and run the tests using pytest as normal.
I have also listed falsifying examples for each of the functions below.
Please note that many of the parameters are 0.0 because Hypothesis tries to shrink falsifying examples. 17 of the 19 functions still fail if the salinity, pressure and fractions strategies are set to have a minimum value of 1 instead of 0.
SP_from_C does not fail anymore if Conductivity is at least ~0.1.
SP_from_SK does not fail anymore if SK is at least ~0.1.
Expected behaviour
I would expect the functions to always return some scalar value rather than NaN.
Environment
Ubuntu 20.04
Python 3.8.10
GSW 3.4.1.post1.dev1+gcede756.d20211122
The text was updated successfully, but these errors were encountered:
Bug
I have been writing Property Based Tests for GSW using the Hypothesis framework. I have tried to provide reasonable inputs for these functions, however they can return
NaN
.The following ranges were used:
The following functions are affected:
CT_from_rho
SA_from_rho
SP_from_C
SP_from_SK
ice_fraction_to_freeze_seawater
melting_ice_SA_CT_ratio
melting_ice_SA_CT_ratio_poly
melting_ice_into_seawater
melting_seaice_SA_CT_ratio
melting_seaice_SA_CT_ratio_poly
melting_seaice_into_seawater
seaice_fraction_to_freeze_seawater
SA_freezing_from_CT
SA_freezing_from_CT_poly
SA_freezing_from_t
SA_freezing_from_t_poly
pressure_freezing_CT
SA_from_SP_Baltic
SP_from_SA_Baltic
Resources
I used these resources to generate the input ranges. If they are incorrect, please let me know and I can adjust my tests and rerun.
To Reproduce
I have added tests to this branch and added
Hypothesis
as a dependency torequirements-dev.txt
. Clone the repo, checkout the branch, install the dependencies and run the tests usingpytest
as normal.I have also listed falsifying examples for each of the functions below.
Please note that many of the parameters are
0.0
because Hypothesis tries to shrink falsifying examples. 17 of the 19 functions still fail if thesalinity
,pressure
andfractions
strategies are set to have a minimum value of1
instead of0
.SP_from_C
does not fail anymore if Conductivity is at least~0.1
.SP_from_SK
does not fail anymore ifSK
is at least~0.1
.Expected behaviour
I would expect the functions to always return some scalar value rather than
NaN
.Environment
The text was updated successfully, but these errors were encountered: