hgrecco / pint-pandas

Pandas support for pint
Other
172 stars 42 forks source link

Make PintTypes use pint.get_application_registry #38

Closed zobac closed 2 years ago

zobac commented 4 years ago

If the user defines pint._APP_REGISTRY (pint.set_application_registry) PintType.ureg will be that registry. Otherwise it will be the default registry defined with "default_en.txt"

This provides a means of guaranteeing PintTypes will use the same UnitRegistry.

carlsmedstad commented 4 years ago

This does not work as get_application_registry() is defined after pint_array is imported and the body of PintType is executed.

Played around with this a bit and tried replacing PintType.ureg in __new__() with no success unfortunately.

andrewgsavage commented 3 years ago

I tried something and it seems to work https://github.com/hgrecco/pint-pandas/pull/63/files, it lets me import pint.

No idea why doing that works and this doesn't.

andrewgsavage commented 3 years ago

Never mind, that breaks the import in pint.

I think we'd have to remove the import in pint for this to work. https://github.com/hgrecco/pint/blob/master/pint/__init__.py#L39

andrewgsavage commented 2 years ago

this was done in https://github.com/hgrecco/pint-pandas/pull/67