-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Percent (and python identifiers) characters not allowed when definining UnitRegistry #38
Comments
Ick, yeah… I can see that being a potential problem. It might be a while before I can get to looking at this problem as not many of us get to work with Python stuff these days. Do you know if it happens with a particular release of Alternatively, if you do not require unit conversion, you can remove |
Thanks for your reply! It is happening with pint 0.20.1, but I think the issue comes from trying to use python identifiers to define the UnitRegistry - so no special characters. Perhaps they can all be treated as: ureg.define('fraction = [] = frac') But I am not sure how to recognize and assign the unit string from haystack |
Could those affected please try this branch and let me know how they go? https://github.com/widesky/hszinc/tree/bugfix/WC-5825-issue38-pint-percent I had some fun and games, because At this time, I am not testing on Python 2.7. Not sure if I should bother actually going forward, if it breaks now, it breaks. But anyway… that branch should resolve the issues with |
Error under: def define_haystack_units() in pintutil.py
DefinitionSyntaxError: Cannot define '%' (UnitDefinition): is not a valid unit name (must follow Python identifier rules)
1,0-1,10 % = [] = %
Percentage units must be defined some other way. Additionally, DefinitionSyntaxError: missing unary operator "%" is thrown when tried to bypass with following code:
ureg = UnitRegistry(on_redefinition='ignore')
ureg.define("percent = [] = %")
ureg('50 %')
This error prevents hszinc to be pip installed
versions:
hszinc - 1.3.1
pint - 0.20.1
The text was updated successfully, but these errors were encountered: