From 6483353b66bbd1e923b0682ed2c9496b7c3f8205 Mon Sep 17 00:00:00 2001 From: Tom Gillespie Date: Mon, 8 Jul 2024 08:10:59 -0400 Subject: [PATCH] ensure uncertainties does not depend on numpy (#2001) --- pint/compat.py | 5 ++++- pint/testsuite/test_issues.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pint/compat.py b/pint/compat.py index 32ad04afb..b968803ce 100644 --- a/pint/compat.py +++ b/pint/compat.py @@ -75,7 +75,8 @@ class BehaviorChangeWarning(UserWarning): try: from uncertainties import UFloat, ufloat - from uncertainties import unumpy as unp + + unp = None HAS_UNCERTAINTIES = True except ImportError: @@ -92,6 +93,8 @@ class BehaviorChangeWarning(UserWarning): HAS_NUMPY = True NUMPY_VER = np.__version__ if HAS_UNCERTAINTIES: + from uncertainties import unumpy as unp + NUMERIC_TYPES = (Number, Decimal, ndarray, np.number, UFloat) else: NUMERIC_TYPES = (Number, Decimal, ndarray, np.number) diff --git a/pint/testsuite/test_issues.py b/pint/testsuite/test_issues.py index c4e42eacc..f726a950c 100644 --- a/pint/testsuite/test_issues.py +++ b/pint/testsuite/test_issues.py @@ -940,6 +940,7 @@ def test_issue_1400(self, sess_registry): assert q2.format_babel("~", locale="es_ES") == "3,1 W/cm" assert q2.format_babel("", locale="es_ES") == "3,1 vatios por centímetro" + @helpers.requires_numpy() @helpers.requires_uncertainties() def test_issue1611(self, module_registry): from numpy.testing import assert_almost_equal