dalito / ucumvert Goto Github PK
View Code? Open in Web Editor NEWPython parser for UCUM (Unified Code for Units of Measure) incl. converter to pint units
License: MIT License
Python parser for UCUM (Unified Code for Units of Measure) incl. converter to pint units
License: MIT License
A new UCUM release (v2.2) was published end of June 2024. We should review if ucumvert needs to be adapted.
For more see https://github.com/ucum-org/ucum/releases/tag/v2.2
Specification with highlighted changes since v.21 (2017): https://ucum.org/pre/diff.php
> g.m2-1
No terminal matches '-' in the current parser context, at line 1 col 5
g.m2-1
^
Expected one of:
* ANNOTATION
* OPERATOR
This is fine according to the validator:
https://lhncbc.github.io/ucum-lhc/demo.html
These all work:
m2
g/m2
g.m-1
(ok semantically doesn't make sense...)So it's some combination
coverage report -> markdown -> job summary
This should be not too difficult to add. Most unclear is how to extend pint best for this kind of conversion.
The idea is to add methods get the corresponding UCUM string from pint quantities and pint units:
>>> q = 5 * ureg("m/kg**3)
>>> q
<Quantity(5, 'kilogram / meter ** 3')>
>>> q.to_ucum()
'kg.m-3'
>>> u = q.units
>>> u
<Unit('kilogram / meter ** 3')>
>>> u.to_ucum()
'kg.m-3'
pip install -e .
ERROR: File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode: /Users/cjm/repos/ucumvert
(A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)
this did work for me however:
hatch run ucumvert
Enter UCUM unit code to parse, or 'q' to quit.
but I also needed to add pydot to the dependencies to avoid runtime error
Hi, I think there is a problem when converting a IU with a prefix to a Pint unit:
Input : m[IU]/L
(from the UCUM examples list, #403)
milliinternational_unit / liter
meter * international_unit / liter
Note that k[IU]/L
is also not converted correctly to Pint.
I would be glad to help, but I'm not sure where to start since the Pint documentation says regarding prefixes that
[...] It is important to note that prefixed defined in this way can be used with any unit, including non-metric ones (e.g. kiloinch is valid for Pint)
So I'm not sure how mX
is not interpreted as milliX
๐ค
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.