8000 importing pint_xarray breaks Quantity.__round__ · Issue #189 · xarray-contrib/pint-xarray · GitHub
[go: up one dir, main page]

Skip to content
importing pint_xarray breaks Quantity.__round__ #189
Closed
@zobac

Description

@zobac

When pint_xarray is imported it sets pint.application_registry.force_ndarray_like = True Once this is done rounding Quantities raises an exception because ndarrays have no round method.

import pint
UREG = pint.UnitRegistry()
pint.set_application_registry(UREG)
round(UREG.Quantity('1.378533532 m'))
<Quantity(1.0, 'meter')>
import pint_xarray
round(UREG.Quantity('1.378533532 m'))
Traceback (most recent call last):
  Python Shell, prompt 6, line 1
    # Used internally for debug sandbox under external interpreter
  File "E:\Envs\xarray311\Lib\site-packages\pint\facets\plain\quantity.py", line 1395, in __round__
    return self.__class__(round(self._magnitude, ndigits=ndigits), self._units)
builtins.TypeError: type numpy.ndarray doesn't define __round__ method

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0