Skip to content

Commit

Permalink
ensure uncertainties does not depend on numpy
Browse files Browse the repository at this point in the history
fix import ordering to ensure that uncertainties can be used without
numpy, before this the check assumed that numpy was always installed

update test_issue1611 to use requires_numpy since uncertainties and
numpy are now decoupled
  • Loading branch information
tgbugs committed Jun 28, 2024
1 parent ad02b87 commit 73a4174
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pint/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pint/testsuite/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,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
Expand Down

0 comments on commit 73a4174

Please sign in to comment.