Closed davidclemens closed 1 year ago
I ran into this because of an error in calkulate. But I just noticed that you fixed that one in calculate in this commit.
Hey @davidclemens, thanks for looking into this!
At this point the intention is really that most users of PyCO2SYS will use only the top-level pyco2.sys
function (which is deliberately the only part of the package that has its API documented). This function (in theory) takes care of all the checks that you describe above, for all the arguments, before calling these 'smaller' functions, rather than having individual checks built in to all the smaller functions themselves. Essentially, the current attitude is, if someone is advanced enough to dig into the undocumented part of the code, then they need to take care of their own variable types (i.e. use Numpy arrays, not lists, and make sure to use valid values).
So if you run all the examples through pyco2.sys(opt_gas_constant=...)['gas_constant']
instead, then I think you'll get the 'expected' behaviour.
(And yes, there was an error there, but Calkulate v23.3 should now play nicely with PyCO2SYS v1.8.1!)
The code of
RGasConstant
suggests that the function argumentWhichR
can be supplied as an array and that the returned variableRGas
will be of the same shape asWhichR
.However, if
WhichR
is an array the isequal test (e.g.WhichR == 1
) will always return false, leaving the default value inRGas
, which isnan
. ExamplesSo input checks are necessary:
WhichR
inputs that are not scalar need to be numpy arrays of integers in the range from 1 to 3Please correct me, if this behaviour is intentional or I misunderstood anything.
Thanks for maintaining this awesome tool!