diff --git a/pint/compat.py b/pint/compat.py index 4f34a1843..552ff3f7e 100644 --- a/pint/compat.py +++ b/pint/compat.py @@ -325,21 +325,28 @@ def isnan(obj: Any, check_all: bool) -> Union[bool, Iterable[bool]]: Always return False for non-numeric types. """ if is_duck_array_type(type(obj)): - if obj.dtype.kind in "if": + if obj.dtype.kind in "ifc": out = np.isnan(obj) elif obj.dtype.kind in "Mm": out = np.isnat(obj) else: - # Not a numeric or datetime type - out = np.full(obj.shape, False) + if HAS_UNCERTAINTIES: + try: + out = unp.isnan(obj) + except TypeError: + # Not a numeric or UFloat type + out = np.full(obj.shape, False) + else: + # Not a numeric or datetime type + out = np.full(obj.shape, False) return out.any() if check_all else out if isinstance(obj, np_datetime64): return np.isnat(obj) + elif HAS_UNCERTAINTIES and isinstance(obj, UFloat): + return unp.isnan(obj) try: return math.isnan(obj) except TypeError: - if HAS_UNCERTAINTIES: - return unp.isnan(obj) return False diff --git a/pint/facets/__init__.py b/pint/facets/__init__.py index 4fd1597a6..22fbc6ce1 100644 --- a/pint/facets/__init__.py +++ b/pint/facets/__init__.py @@ -7,7 +7,7 @@ keeping each part small enough to be hackable. Each facet contains one or more of the following modules: - - definitions: classes describing an specific unit related definiton. + - definitions: classes describing specific unit-related definitons. These objects must be immutable, pickable and not reference the registry (e.g. ContextDefinition) - objects: classes and functions that encapsulate behavior (e.g. Context) - registry: implements a subclass of PlainRegistry or class that can be diff --git a/pint/testsuite/test_issues.py b/pint/testsuite/test_issues.py index add5b4c01..c98ac61bf 100644 --- a/pint/testsuite/test_issues.py +++ b/pint/testsuite/test_issues.py @@ -881,6 +881,7 @@ def test_issue_1300(self): m = module_registry.Measurement(1, 0.1, "meter") assert m.default_format == "~P" + @helpers.requires_babel() def test_issue_1400(self, sess_registry): q1 = 3 * sess_registry.W q2 = 3 * sess_registry.W / sess_registry.cm diff --git a/pyproject.toml b/pyproject.toml index cdec7775e..4b6b7312d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,8 +44,7 @@ testbase = [ "pytest", "pytest-cov", "pytest-subtests", - "pytest-benchmark", - "babel" + "pytest-benchmark" ] test = [ "pytest",