Skip to content

Commit 4e82387

Browse files
authored
Merge pull request python-quantities#238 from mscheltienne/np2-fix
Fix numpy version string parsing
2 parents 9720066 + 8f99a26 commit 4e82387

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ dist
99
.idea
1010
.*cache/
1111
_version.py
12-
MANIFEST
12+
MANIFEST
13+
.venv

quantities/dimensionality.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from .registry import unit_registry
1010
from .decorators import memoize
1111

12-
_np_version = tuple(map(int, np.__version__.split('.')))
12+
_np_version = tuple(map(int, np.__version__.split(".dev")[0].split(".")))
13+
1314

1415
def assert_isinstance(obj, types):
1516
try:

quantities/quantity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def __array_prepare__(self, obj, context=None):
291291
return res
292292

293293
def __array_wrap__(self, obj, context=None, return_scalar=False):
294-
_np_version = tuple(map(int, np.__version__.split('.')))
294+
_np_version = tuple(map(int, np.__version__.split(".dev")[0].split(".")))
295295
# For NumPy < 2.0 we do old behavior
296296
if _np_version < (2, 0, 0):
297297
if not isinstance(obj, Quantity):

quantities/tests/test_umath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .. import units as pq
44
from .common import TestCase, unittest
55

6-
_np_version = tuple(map(int, np.__version__.split('.')))
6+
_np_version = tuple(map(int, np.__version__.split(".dev")[0].split(".")))
77

88

99
class TestUmath(TestCase):

0 commit comments

Comments
 (0)