Skip to content
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

Quantity.default_format not initialised #1970

Closed
andrewgsavage opened this issue Apr 24, 2024 · 1 comment
Closed

Quantity.default_format not initialised #1970

andrewgsavage opened this issue Apr 24, 2024 · 1 comment

Comments

@andrewgsavage
Copy link
Collaborator

https://github.com/hgrecco/pint-pandas/actions/runs/8823901297/job/24225328915?pr=226#step:11:2900
Quantity.default_format is no longer initialised causing a pint-pandas test to fail, probably since #1457 or #1503 ?

>>> ureg = pint.UnitRegistry()
>>> q = ureg.Quantity(1.25, "m ** 2 / s ** 2")
>>> q.default_format
Traceback (most recent call last):
  File "D:\repos\pint\pint\facets\numpy\quantity.py", line 248, in __getattr__
    return getattr(self._magnitude, item)
AttributeError: 'float' object has no attribute 'default_format'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\repos\pint\pint\facets\numpy\quantity.py", line 250, in __getattr__
    raise AttributeError(
AttributeError: Neither Quantity object nor its magnitude (1.25) has attribute 'default_format'
>>> ureg.default_format = "~P"
<stdin>:1: DeprecationWarning: This function will be removed in future versions of pint.
Use ureg.formatter.default_format
>>> q.default_format
Traceback (most recent call last):
  File "D:\repos\pint\pint\facets\numpy\quantity.py", line 248, in __getattr__
    return getattr(self._magnitude, item)
AttributeError: 'float' object has no attribute 'default_format'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\repos\pint\pint\facets\numpy\quantity.py", line 250, in __getattr__
    raise AttributeError(
AttributeError: Neither Quantity object nor its magnitude (1.25) has attribute 'default_format'
>>> q.default_format = ".3fP"
>>> q.default_format
'.3fP'

Should I change the pint-pandas test/behaviour, or was this unintentional?

@andrewgsavage
Copy link
Collaborator Author

ah I'd missed DeprecationWarning: This function will be removed in future versions of pint. Use ureg.formatter.default_format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant