Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7fef045

Browse filesBrowse files
committed
MAINT: fix numpy.testing on Python < 3.13
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 900f876 commit 7fef045
Copy full SHA for 7fef045

File tree

Expand file treeCollapse file tree

2 files changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-3
lines changed

‎numpy/testing/_private/utils.py

Copy file name to clipboardExpand all lines: numpy/testing/_private/utils.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Utility function to facilitate testing.
33
44
"""
5-
import importlib.metadata
65
import os
76
import sys
87
import pathlib
@@ -31,6 +30,13 @@
3130

3231
from io import StringIO
3332

33+
34+
if sys.version_info >= (3, 13):
35+
import importlib.metadata as importlib_metadata
36+
else:
37+
import importlib_metadata
38+
39+
3440
__all__ = [
3541
'assert_equal', 'assert_almost_equal', 'assert_approx_equal',
3642
'assert_array_equal', 'assert_array_less', 'assert_string_equal',
@@ -57,8 +63,8 @@ class KnownFailureException(Exception):
5763
verbose = 0
5864

5965
try:
60-
np_dist = importlib.metadata.distribution('numpy')
61-
except importlib.metadata.PackageNotFoundError:
66+
np_dist = importlib_metadata.distribution('numpy')
67+
except importlib_metadata.PackageNotFoundError:
6268
IS_INSTALLED = IS_EDITABLE = False
6369
else:
6470
IS_INSTALLED = True

‎requirements/test_requirements.txt

Copy file name to clipboardExpand all lines: requirements/test_requirements.txt
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ mypy==1.14.1; platform_python_implementation != "PyPy"
1919
typing_extensions>=4.2.0
2020
# for optional f2py encoding detection
2121
charset-normalizer
22+
# For importlib.metadata.Distribution.origin
23+
importlib_metadata >= 6.11.0; python_version < '3.13'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.