File fix-tests-numpy-2.4.patch of Package python-joblib
From c559b8feace27e24767f4b2cf84025bf1acdc2bd Mon Sep 17 00:00:00 2001
From: Nanored4498 <nanored.mc@gmail.com>
Date: Thu, 8 Jan 2026 17:21:11 +0100
Subject: [PATCH 1/8] repare CI
---
joblib/test/test_numpy_pickle.py | 54 ++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 17 deletions(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index ed320497b..b648f53c3 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -416,6 +416,22 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
if (re.search("_0.1.+.pkl$", filename_base) and mmap_mode is not None)
else 0
)
+
+ if np.__version__.split(".") >= "2.4.0".split("."):
+ prefix = "joblib_"
+ version_index = filename_base.find(prefix) + len(prefix)
+ joblib_version = filename_base[version_index:]
+
+ def check_version(v):
+ return joblib_version.startswith(v)
+
+ if check_version("0.9."):
+ expected_nb_user_warnings += 1
+ if "compressed" in filename_base:
+ expected_nb_user_warnings += 2
+ elif check_version("0.10.") or check_version("0.11."):
+ expected_nb_user_warnings += 4
+
expected_nb_warnings = (
expected_nb_deprecation_warnings + expected_nb_user_warnings
)
@@ -425,23 +441,27 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
f"{[w.message for w in warninfo]}"
)
- deprecation_warnings = [
- w for w in warninfo if issubclass(w.category, DeprecationWarning)
- ]
- user_warnings = [w for w in warninfo if issubclass(w.category, UserWarning)]
- for w in deprecation_warnings:
- assert (
- str(w.message)
- == "The file '{0}' has been generated with a joblib "
- "version less than 0.10. Please regenerate this "
- "pickle file.".format(filename)
- )
-
- for w in user_warnings:
- escaped_filename = re.escape(filename)
- assert re.search(
- f"memmapped.+{escaped_filename}.+segmentation fault", str(w.message)
- )
+ for w in warninfo:
+ if issubclass(w.category, DeprecationWarning):
+ assert (
+ str(w.message)
+ == "The file '{0}' has been generated with a joblib "
+ "version less than 0.10. Please regenerate this "
+ "pickle file.".format(filename)
+ )
+ elif issubclass(w.category, np.exceptions.VisibleDeprecationWarning):
+ assert (
+ str(w.message)
+ == "dtype(): align should be passed as Python or NumPy "
+ "boolean but got `align=0`. Did you mean to pass a tuple "
+ "to create a subarray type? (Deprecated NumPy 2.4)"
+ )
+ elif issubclass(w.category, UserWarning):
+ escaped_filename = re.escape(filename)
+ assert re.search(
+ f"memmapped.+{escaped_filename}.+segmentation fault",
+ str(w.message),
+ )
for result, expected in zip(result_list, expected_list):
if isinstance(expected, np.ndarray):
From 05f9f53475514af65bc181529624712bb8163502 Mon Sep 17 00:00:00 2001
From: Nanored4498 <nanored.mc@gmail.com>
Date: Fri, 9 Jan 2026 10:20:42 +0100
Subject: [PATCH 2/8] Better version check
---
joblib/test/test_numpy_pickle.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index b648f53c3..1f84e6f7b 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -16,6 +16,8 @@
from contextlib import closing
from pathlib import Path
+from packaging.version import Version
+
try:
import lzma
except ImportError:
@@ -417,7 +419,11 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
else 0
)
- if np.__version__.split(".") >= "2.4.0".split("."):
+ # Account for the VisibleDeprecationWarning raised by
+ # numpy 2.4+ with align been of the wrong type
+ numpyDepreciationWarning = False
+ if Version(np.__version__) >= Version("2.4.0"):
+ numpyDepreciationWarning = True
prefix = "joblib_"
version_index = filename_base.find(prefix) + len(prefix)
joblib_version = filename_base[version_index:]
@@ -429,7 +435,7 @@ def check_version(v):
expected_nb_user_warnings += 1
if "compressed" in filename_base:
expected_nb_user_warnings += 2
- elif check_version("0.10.") or check_version("0.11."):
+ else:
expected_nb_user_warnings += 4
expected_nb_warnings = (
@@ -449,7 +455,9 @@ def check_version(v):
"version less than 0.10. Please regenerate this "
"pickle file.".format(filename)
)
- elif issubclass(w.category, np.exceptions.VisibleDeprecationWarning):
+ elif numpyDepreciationWarning and issubclass(
+ w.category, np.exceptions.VisibleDeprecationWarning
+ ):
assert (
str(w.message)
== "dtype(): align should be passed as Python or NumPy "
@@ -462,6 +470,8 @@ def check_version(v):
f"memmapped.+{escaped_filename}.+segmentation fault",
str(w.message),
)
+ else:
+ raise Exception(f"No warning of type {w.category} is expected")
for result, expected in zip(result_list, expected_list):
if isinstance(expected, np.ndarray):
From e1817d9d9b4ad88d98ad1b3c83fb48db9136eb63 Mon Sep 17 00:00:00 2001
From: Thomas Moreau <thomas.moreau.2010@gmail.com>
Date: Fri, 9 Jan 2026 11:09:48 +0100
Subject: [PATCH 3/8] CLN clarify numpy deprecation warning handling
---
joblib/test/test_numpy_pickle.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index 1f84e6f7b..bce9e08c6 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -421,9 +421,9 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
# Account for the VisibleDeprecationWarning raised by
# numpy 2.4+ with align been of the wrong type
- numpyDepreciationWarning = False
+ check_numpy_depreciation_warning = False
if Version(np.__version__) >= Version("2.4.0"):
- numpyDepreciationWarning = True
+ check_numpy_depreciation_warning = True
prefix = "joblib_"
version_index = filename_base.find(prefix) + len(prefix)
joblib_version = filename_base[version_index:]
@@ -455,7 +455,13 @@ def check_version(v):
"version less than 0.10. Please regenerate this "
"pickle file.".format(filename)
)
- elif numpyDepreciationWarning and issubclass(
+ elif issubclass(w.category, UserWarning):
+ escaped_filename = re.escape(filename)
+ assert re.search(
+ f"memmapped.+{escaped_filename}.+segmentation fault",
+ str(w.message),
+ )
+ elif check_numpy_depreciation_warning and issubclass(
w.category, np.exceptions.VisibleDeprecationWarning
):
assert (
@@ -464,12 +470,6 @@ def check_version(v):
"boolean but got `align=0`. Did you mean to pass a tuple "
"to create a subarray type? (Deprecated NumPy 2.4)"
)
- elif issubclass(w.category, UserWarning):
- escaped_filename = re.escape(filename)
- assert re.search(
- f"memmapped.+{escaped_filename}.+segmentation fault",
- str(w.message),
- )
else:
raise Exception(f"No warning of type {w.category} is expected")
From 2c513ace44928b05c264a5be0d9e809b5c35a501 Mon Sep 17 00:00:00 2001
From: Thomas Moreau <thomas.moreau.2010@gmail.com>
Date: Fri, 9 Jan 2026 11:11:13 +0100
Subject: [PATCH 4/8] Update joblib/test/test_numpy_pickle.py
---
joblib/test/test_numpy_pickle.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index bce9e08c6..7e68b9942 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -428,10 +428,7 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
version_index = filename_base.find(prefix) + len(prefix)
joblib_version = filename_base[version_index:]
- def check_version(v):
- return joblib_version.startswith(v)
-
- if check_version("0.9."):
+ if joblib_version.startswith("0.9."):
expected_nb_user_warnings += 1
if "compressed" in filename_base:
expected_nb_user_warnings += 2
From 65d1da5c582bf99032481a4d0b65ce7ce0640fba Mon Sep 17 00:00:00 2001
From: Thomas Moreau <thomas.moreau.2010@gmail.com>
Date: Fri, 9 Jan 2026 11:16:12 +0100
Subject: [PATCH 5/8] Restore UserWarning check in test_numpy_pickle
Reintroduce UserWarning check for segmentation fault.
---
joblib/test/test_numpy_pickle.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index 7e68b9942..3970fe535 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -452,12 +452,6 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
"version less than 0.10. Please regenerate this "
"pickle file.".format(filename)
)
- elif issubclass(w.category, UserWarning):
- escaped_filename = re.escape(filename)
- assert re.search(
- f"memmapped.+{escaped_filename}.+segmentation fault",
- str(w.message),
- )
elif check_numpy_depreciation_warning and issubclass(
w.category, np.exceptions.VisibleDeprecationWarning
):
@@ -467,6 +461,12 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
"boolean but got `align=0`. Did you mean to pass a tuple "
"to create a subarray type? (Deprecated NumPy 2.4)"
)
+ elif issubclass(w.category, UserWarning):
+ escaped_filename = re.escape(filename)
+ assert re.search(
+ f"memmapped.+{escaped_filename}.+segmentation fault",
+ str(w.message),
+ )
else:
raise Exception(f"No warning of type {w.category} is expected")
From 0979956337eb5f76c08ee4aeafd0597c6c83aefa Mon Sep 17 00:00:00 2001
From: Nanored4498 <nanored.mc@gmail.com>
Date: Fri, 9 Jan 2026 16:02:06 +0100
Subject: [PATCH 6/8] now ignore VisibleDeprecationWarning
---
joblib/test/test_numpy_pickle.py | 62 +++++++++++++-------------------
1 file changed, 24 insertions(+), 38 deletions(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index 3970fe535..cb6a7d878 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -16,8 +16,6 @@
from contextlib import closing
from pathlib import Path
-from packaging.version import Version
-
try:
import lzma
except ImportError:
@@ -407,68 +405,56 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
try:
with warnings.catch_warnings(record=True) as warninfo:
warnings.simplefilter("always")
+ # Ignore VisibleDeprecationWarning raised by
+ # numpy 2.4+ with align been of the wrong type
+ if hasattr(np, "exceptions") and hasattr(
+ np.exceptions, "VisibleDeprecationWarning"
+ ):
+ warnings.filterwarnings(
+ "ignore", category=np.exceptions.VisibleDeprecationWarning
+ )
result_list = numpy_pickle.load(filename, mmap_mode=mmap_mode)
+
filename_base = os.path.basename(filename)
expected_nb_deprecation_warnings = (
1 if ("_0.9" in filename_base or "_0.8.4" in filename_base) else 0
)
+ deprecation_warnings = []
expected_nb_user_warnings = (
3
if (re.search("_0.1.+.pkl$", filename_base) and mmap_mode is not None)
else 0
)
-
- # Account for the VisibleDeprecationWarning raised by
- # numpy 2.4+ with align been of the wrong type
- check_numpy_depreciation_warning = False
- if Version(np.__version__) >= Version("2.4.0"):
- check_numpy_depreciation_warning = True
- prefix = "joblib_"
- version_index = filename_base.find(prefix) + len(prefix)
- joblib_version = filename_base[version_index:]
-
- if joblib_version.startswith("0.9."):
- expected_nb_user_warnings += 1
- if "compressed" in filename_base:
- expected_nb_user_warnings += 2
- else:
- expected_nb_user_warnings += 4
-
- expected_nb_warnings = (
- expected_nb_deprecation_warnings + expected_nb_user_warnings
- )
- assert len(warninfo) == expected_nb_warnings, (
- "Did not get the expected number of warnings. Expected "
- f"{expected_nb_warnings} but got warnings: "
- f"{[w.message for w in warninfo]}"
- )
+ user_warnings = []
for w in warninfo:
if issubclass(w.category, DeprecationWarning):
+ deprecation_warnings.append(w.message)
assert (
str(w.message)
== "The file '{0}' has been generated with a joblib "
"version less than 0.10. Please regenerate this "
"pickle file.".format(filename)
)
- elif check_numpy_depreciation_warning and issubclass(
- w.category, np.exceptions.VisibleDeprecationWarning
- ):
- assert (
- str(w.message)
- == "dtype(): align should be passed as Python or NumPy "
- "boolean but got `align=0`. Did you mean to pass a tuple "
- "to create a subarray type? (Deprecated NumPy 2.4)"
- )
elif issubclass(w.category, UserWarning):
+ user_warnings.append(w.message)
escaped_filename = re.escape(filename)
assert re.search(
f"memmapped.+{escaped_filename}.+segmentation fault",
str(w.message),
)
- else:
- raise Exception(f"No warning of type {w.category} is expected")
+
+ assert len(deprecation_warnings) == expected_nb_deprecation_warnings, (
+ "Did not get the expected number of deprecation warnings. "
+ f"Expected {expected_nb_deprecation_warnings} "
+ "but got warnings: {deprecation_warnings}"
+ )
+ assert len(user_warnings) == expected_nb_user_warnings, (
+ "Did not get the expected number of user warnings. "
+ f"Expected {expected_nb_user_warnings} "
+ "but got warnings: {user_warnings}"
+ )
for result, expected in zip(result_list, expected_list):
if isinstance(expected, np.ndarray):
From eb4dbaab32e07053eaf4f17055c232992d0e62ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= <loic.esteve@ymail.com>
Date: Mon, 12 Jan 2026 07:07:49 +0100
Subject: [PATCH 7/8] Simpler strategy
---
joblib/test/test_numpy_pickle.py | 66 ++++++++++++++------------------
1 file changed, 29 insertions(+), 37 deletions(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index cb6a7d878..a6920b035 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -405,57 +405,49 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
try:
with warnings.catch_warnings(record=True) as warninfo:
warnings.simplefilter("always")
- # Ignore VisibleDeprecationWarning raised by
- # numpy 2.4+ with align been of the wrong type
- if hasattr(np, "exceptions") and hasattr(
- np.exceptions, "VisibleDeprecationWarning"
- ):
- warnings.filterwarnings(
- "ignore", category=np.exceptions.VisibleDeprecationWarning
- )
+ # Ignore numpy >= 2.4 warning when load old pickle where
+ # align=0 but it should be a Python or Numpy boolean
+ warnings.filterwarnings(
+ "ignore", message=".+align should be passed.+boolean.+align=0"
+ )
result_list = numpy_pickle.load(filename, mmap_mode=mmap_mode)
-
filename_base = os.path.basename(filename)
expected_nb_deprecation_warnings = (
1 if ("_0.9" in filename_base or "_0.8.4" in filename_base) else 0
)
- deprecation_warnings = []
expected_nb_user_warnings = (
3
if (re.search("_0.1.+.pkl$", filename_base) and mmap_mode is not None)
else 0
)
- user_warnings = []
-
- for w in warninfo:
- if issubclass(w.category, DeprecationWarning):
- deprecation_warnings.append(w.message)
- assert (
- str(w.message)
- == "The file '{0}' has been generated with a joblib "
- "version less than 0.10. Please regenerate this "
- "pickle file.".format(filename)
- )
- elif issubclass(w.category, UserWarning):
- user_warnings.append(w.message)
- escaped_filename = re.escape(filename)
- assert re.search(
- f"memmapped.+{escaped_filename}.+segmentation fault",
- str(w.message),
- )
-
- assert len(deprecation_warnings) == expected_nb_deprecation_warnings, (
- "Did not get the expected number of deprecation warnings. "
- f"Expected {expected_nb_deprecation_warnings} "
- "but got warnings: {deprecation_warnings}"
+ expected_nb_warnings = (
+ expected_nb_deprecation_warnings + expected_nb_user_warnings
)
- assert len(user_warnings) == expected_nb_user_warnings, (
- "Did not get the expected number of user warnings. "
- f"Expected {expected_nb_user_warnings} "
- "but got warnings: {user_warnings}"
+ assert len(warninfo) == expected_nb_warnings, (
+ "Did not get the expected number of warnings. Expected "
+ f"{expected_nb_warnings} but got warnings: "
+ f"{[w.message for w in warninfo]}"
)
+ deprecation_warnings = [
+ w for w in warninfo if issubclass(w.category, DeprecationWarning)
+ ]
+ user_warnings = [w for w in warninfo if issubclass(w.category, UserWarning)]
+ for w in deprecation_warnings:
+ assert (
+ str(w.message)
+ == "The file '{0}' has been generated with a joblib "
+ "version less than 0.10. Please regenerate this "
+ "pickle file.".format(filename)
+ )
+
+ for w in user_warnings:
+ escaped_filename = re.escape(filename)
+ assert re.search(
+ f"memmapped.+{escaped_filename}.+segmentation fault", str(w.message)
+ )
+
for result, expected in zip(result_list, expected_list):
if isinstance(expected, np.ndarray):
expected = _ensure_native_byte_order(expected)
From afc24f82511b8f536e0344c98a722c73081fedf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= <loic.esteve@ymail.com>
Date: Mon, 12 Jan 2026 07:08:42 +0100
Subject: [PATCH 8/8] Tweak wording
---
joblib/test/test_numpy_pickle.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/joblib/test/test_numpy_pickle.py b/joblib/test/test_numpy_pickle.py
index a6920b035..af4214edc 100644
--- a/joblib/test/test_numpy_pickle.py
+++ b/joblib/test/test_numpy_pickle.py
@@ -405,7 +405,7 @@ def _check_pickle(filename, expected_list, mmap_mode=None):
try:
with warnings.catch_warnings(record=True) as warninfo:
warnings.simplefilter("always")
- # Ignore numpy >= 2.4 warning when load old pickle where
+ # Ignore numpy >= 2.4 warning when loading old pickles, where
# align=0 but it should be a Python or Numpy boolean
warnings.filterwarnings(
"ignore", message=".+align should be passed.+boolean.+align=0"