Closed cmutel closed 1 year ago
Hi @cmutel ,
thanks for merging my PR. The things you request are doable but some of them I wouldn't recommend. Here are my thoughts:
I agree.
Don't test if pint is available: fine. But I don't think it's a good idea to remove the config. I would like to give the user the possibility to switch off the pint parser when using bw2data.parameters. This is because some of the default units implemented in pint may overlap with the user parameter name space (e.g. a = year, b = barn, c = speed of light). This should not be a problem if the parameters are properly defined but may lead to unexpected results if parameters are renamed or removed and not all dependent formulas are updated.
Not sure Interpreter
is a good choice because then bw2parameters.Interpreter
will overlap with asteval.Interpreter
. Are you suggesting this because you want PintInterpreter/PintParameterSet to be the default or is there another reason?
The reason why I introduced classes is because this way I can re-use the tests of the (default) Interpreter for the PintInterpreter. I want to make sure that the PintInterpreter behaves exactly the same as the (default) Interpreter for the base cases. I don't know how to achieve this with pure functions.
Agreed.
Removal is not recommended. We need one central UnitRegistry instance, otherwise unit parsing becomes very slow. Should I rename it to pint_wrapper.py
?
Thanks for your detailed response, and for all the work you have done here.
I agree with each of your conclusions. You can decide on the naming of PintWrapper
, probably easiest to leave it alone as it works.
@BenPortner Thanks for the work in incorporating Pint. I have merged the PR, but after playing with this a bit more, I think we need some substantial cleanup before making a release. I tried to do this myself, but I am not able to understand some of the hidden assumptions (and there isn't any documentation yet), so am really struggling. I would like the following:
pint
requiredpint
is available (including removal ofconfig
)DefaultInterpreter
toInterpreter
andDefaultParameterSet
toParameterSet
utils
PintWrapper
if at all possible; otherwise, change filename and document what this is doing@tngTUDOR FYI