Open Helveg opened 5 years ago
There is no integration/conversion currently, but of course this is possible :)
Is there already an obvious way to do it? Currently I'm trying to use the unit name to get the corresponding pint unit but they're not a one on one relation...
On Tue, 23 Jul 2019, 13:31 Niels Mündler, notifications@github.com wrote:
There is no integration/conversion currently, but of course this is possible :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nielstron/quantulum3/issues/133?email_source=notifications&email_token=AG4VQS5R5CPIRFXVBVVXG5TQA3T2ZA5CNFSM4IGCYBN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2S2ERQ#issuecomment-514171462, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4VQSYYF4YMGJBYRUQNLBLQA3T2ZANCNFSM4IGCYBNQ .
I do not know of an obvious way. One could think about including matching pint units in the units.json files.
When trying to work with the current state of the project I can only suggest trying the different possible names and abbreviations of a unit (they are iterable with .unit.name
, .unit.surfaces
and .unit.symbols
, also see the unit class definition) with the parse_expression
method of pint. As a security check you can re-parse the stringyfied result and test whether quantulum extracts the same unit again.
I was wondering about this too.
The manipulation section of the docs mentions several other packages for working with quantities. (I'm not sure if astropy.units
builds on one of those, or whether it is yet another representation?)
It's unlikely that each separate package maintainer would want to change their quantity object representations to a common representation, but it would be handy if one of them could act as a bridge to convert to / from the other representations.
Or perhaps it would be better to start a new package whose role was simply to convert object representations between the different packages?
So a ... unit conversion package conversion package ... ;D
On Tue, 6 Aug 2019, 13:58 Tony Hirst, notifications@github.com wrote:
I was wondering about this too.
The manipulation https://github.com/nielstron/quantulum3#manipulation section of the docs mentions several other packages for working with quantities. (I'm not sure if astropy.units https://docs.astropy.org/en/stable/units/ builds on one of those, or whether it is yet another representation?)
It's unlikely that each separate package maintainer would want to change their quantity object representations to a common representation, but it would be handy if one of them could act as a bridge to convert to / from the other representations.
Or perhaps it would be better to start a new package whose role was simply to convert object representations between the different packages?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nielstron/quantulum3/issues/133?email_source=notifications&email_token=AG4VQS24HY2STS3DM5G5AQ3QDFROFA5CNFSM4IGCYBN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3U4YCQ#issuecomment-518638602, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4VQS4W5FU6RM6DIRJ43CDQDFROFANCNFSM4IGCYBNQ .
I was going to post the appropriate that XKCD cartoon, but thought better of it! ;-)
I did some mapping match between unit name/surfaces/symbols of quantulum units and names of units of quantities
library
import quantities as pq
dir(pq)
for e.g. result for 'mass' and 'volume' entities mostly matching each other
mappings = {"short ton": "ton", "kilogram": "kilogram", "gram": "gram", "milligram": "milligram", "atomic mass unit": "dalton", "pound-mass": "pound", "ounce": "ounce", "ton": "ton", "tonne": "tonne", "quintal": "q", "carat": "carat", "bushel": "bushel", "cubic metre": "kiloliter", "cubic centimetre": "millilitre", "litre": "litre", "centilitre": "cl", "decilitre": "dl", "barrel": "barrel", "gallon": "gallon", "quart": "quart", "pint": "pint", "cup": "cup", "fluid ounce": "floz", "tablespoon": "tablespoon", "teaspoon": "teaspoon", "stere": "stere", "peck": "peck"}
Is there any integration/conversion possible to pint units and quantities?