Open MichaelClerx opened 4 years ago
The unit string is added by the cellmlmanip unit store, here: https://github.com/ModellingWebLab/weblab-fc/blob/master/fc/protocol.py#L669
The unit string is made here https://github.com/ModellingWebLab/cellmlmanip/blob/master/cellmlmanip/units.py#L225-L226
This is due to changes in pint
since version 0.10, which I've got installed, possibly these ones in 0.11:
https://github.com/hgrecco/pint/blob/master/CHANGES#L118-L119
Updating pint to 0.16 fixes the issue for me
@jonc125 @MauriceHendrix what do you think, should we raise the required version of PINT in cellmlmanip to the latest one?
@MichaelClerx just ran a test with pint set to 0.16 in a PR and that passes all tests for all the tested python versions so it should be ok from my end.
Thanks. Do you think this issue, where the output of str(self._registry.get_base_units(unit)[0])
has changed from 1.0
to 1
, is big enough for us to say "users have to use at least version 0,16" ?
it doesn't seem to cause any issues for me. If it does for you in the weblab you might consider adjusting the printer to always just print 1 something along the lines of:
def _print_float(self, expr):
""" Handles ``float``s. """
if(float(<number>).is_integer()):
return self._print_int(int(expr))
else:
.....
It's not in the printer, the issue is that I call self._registry.get_base_units(unit)[0]
, which gives me a pint unit, and that unit has a __str__
method that involves printing the float or int, and in older versions it was always a float but now something it's an int.
The result is that str(unit) gives a slightly different output now. Both outputs are correct, but it makes writing tests that use this output slightly harder
So my question is whether we should bump the required version of pint up to the latest version
I'd be happy to bump up!
bumping should be ok