dylanwal / unit_parse

Tool for parsing 'ugly' numbers and units
BSD 3-Clause "New" or "Revised" License
10 stars 3 forks source link

pint ureg #15

Closed andrewgsavage closed 3 days ago

andrewgsavage commented 1 month ago

from the readme:

import pint

u = pint.UnitRegistry()
U = Unit = u.Unit
Q = Quantity = u.Quantity

from unit_parse import parser

# your code from here…

Are you aware of pint's application registry? it was made for this purpose.

pint.set_application_registry(u)
pint.get_application_registry() # returns u
dylanwal commented 1 month ago

I was not aware. I did some looking at the docs and their use is still not clear to me.

Can I use pint.get_application_registry() in my 'unit_parse' package to get a registry that has already been defined (or get new one if none have been previously defined)?

andrewgsavage commented 3 days ago

Can I use pint.get_application_registry() in my 'unit_parse' package to get a registry that has already been defined (or get new one if none have been previously defined)?

yes