68 lines
2.6 KiB
Diff
68 lines
2.6 KiB
Diff
From 855ccd6448d06977f2911d9182d946e8206bae6c Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
|
|
Date: Thu, 18 Apr 2024 11:47:23 +0200
|
|
Subject: [PATCH] Minimal patch for compatibility with pytest 8
|
|
|
|
Inspired from upstream commit which does not apply to pint version we
|
|
have in Fedora
|
|
https://github.com/hgrecco/pint/commit/ba5fb6566dcefc1d7d34dfde48e498d69da05347
|
|
---
|
|
pint/quantity.py | 9 ++++-----
|
|
pint/testing.py | 8 ++++----
|
|
2 files changed, 8 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/pint/quantity.py b/pint/quantity.py
|
|
index 1207b94..2cdb699 100644
|
|
--- a/pint/quantity.py
|
|
+++ b/pint/quantity.py
|
|
@@ -824,12 +824,11 @@ class Quantity(PrettyIPython, SharedRegistryObject, Generic[_MagnitudeType]):
|
|
"""
|
|
|
|
if not isinstance(self.magnitude, numbers.Number):
|
|
- msg = (
|
|
- "to_compact applied to non numerical types "
|
|
- "has an undefined behavior."
|
|
+ warnings.warn(
|
|
+ "to_compact applied to non numerical types has an undefined behavior.",
|
|
+ RuntimeWarning,
|
|
+ stacklevel=2,
|
|
)
|
|
- w = RuntimeWarning(msg)
|
|
- warnings.warn(w, stacklevel=2)
|
|
return self
|
|
|
|
if (
|
|
diff --git a/pint/testing.py b/pint/testing.py
|
|
index 3334675..485a29d 100644
|
|
--- a/pint/testing.py
|
|
+++ b/pint/testing.py
|
|
@@ -42,10 +42,10 @@ def assert_equal(first, second, msg=None):
|
|
if isinstance(m1, ndarray) or isinstance(m2, ndarray):
|
|
np.testing.assert_array_equal(m1, m2, err_msg=msg)
|
|
elif not isinstance(m1, Number):
|
|
- warnings.warn(RuntimeWarning)
|
|
+ warnings.warn("In assert_equal, m1 is not a number ", RuntimeWarning)
|
|
return
|
|
elif not isinstance(m2, Number):
|
|
- warnings.warn(RuntimeWarning)
|
|
+ warnings.warn("In assert_equal, m2 is not a number ", RuntimeWarning)
|
|
return
|
|
elif math.isnan(m1):
|
|
assert math.isnan(m2), msg
|
|
@@ -71,10 +71,10 @@ def assert_allclose(first, second, rtol=1e-07, atol=0, msg=None):
|
|
if isinstance(m1, ndarray) or isinstance(m2, ndarray):
|
|
np.testing.assert_allclose(m1, m2, rtol=rtol, atol=atol, err_msg=msg)
|
|
elif not isinstance(m1, Number):
|
|
- warnings.warn(RuntimeWarning)
|
|
+ warnings.warn("In assert_equal, m1 is not a number ", RuntimeWarning)
|
|
return
|
|
elif not isinstance(m2, Number):
|
|
- warnings.warn(RuntimeWarning)
|
|
+ warnings.warn("In assert_equal, m2 is not a number ", RuntimeWarning)
|
|
return
|
|
elif math.isnan(m1):
|
|
assert math.isnan(m2), msg
|
|
--
|
|
2.44.0
|
|
|