python313Packages.mlxtend: fix build (#371432)
This commit is contained in:
+109
@@ -0,0 +1,109 @@
|
||||
From 360cb75317aecaf6b9abcf24f0577afef75c464e Mon Sep 17 00:00:00 2001
|
||||
From: wxt <3264117476@qq.com>
|
||||
Date: Mon, 6 Jan 2025 20:41:27 +0800
|
||||
Subject: [PATCH] fix(test): replace np.float_ to np.float64
|
||||
|
||||
---
|
||||
mlxtend/_base/_regressor.py | 2 +-
|
||||
mlxtend/_base/tests/test_classifier.py | 2 +-
|
||||
mlxtend/_base/tests/test_cluster.py | 2 +-
|
||||
mlxtend/classifier/multilayerperceptron.py | 2 +-
|
||||
mlxtend/classifier/softmax_regression.py | 2 +-
|
||||
mlxtend/math/linalg.py | 2 +-
|
||||
mlxtend/plotting/tests/test_decision_regions.py | 2 +-
|
||||
7 files changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/mlxtend/_base/_regressor.py b/mlxtend/_base/_regressor.py
|
||||
index e3d0a1d..1d3a5d6 100644
|
||||
--- a/mlxtend/_base/_regressor.py
|
||||
+++ b/mlxtend/_base/_regressor.py
|
||||
@@ -16,7 +16,7 @@ class _Regressor(object):
|
||||
pass
|
||||
|
||||
def _check_target_array(self, y, allowed=None):
|
||||
- if not isinstance(y[0], (float, np.float_)):
|
||||
+ if not isinstance(y[0], (float, np.float64)):
|
||||
raise AttributeError("y must be a float array.\nFound %s" % y.dtype)
|
||||
|
||||
def fit(self, X, y, init_params=True):
|
||||
diff --git a/mlxtend/_base/tests/test_classifier.py b/mlxtend/_base/tests/test_classifier.py
|
||||
index f77f74d..1bbac6d 100644
|
||||
--- a/mlxtend/_base/tests/test_classifier.py
|
||||
+++ b/mlxtend/_base/tests/test_classifier.py
|
||||
@@ -51,7 +51,7 @@ def test_check_labels_not_ok_1():
|
||||
|
||||
|
||||
def test_check_labels_integer_notok():
|
||||
- y = np.array([1.0, 2.0], dtype=np.float_)
|
||||
+ y = np.array([1.0, 2.0], dtype=np.float64)
|
||||
cl = BlankClassifier(print_progress=0, random_seed=1)
|
||||
with pytest.raises(AttributeError) as excinfo:
|
||||
cl._check_target_array(y)
|
||||
diff --git a/mlxtend/_base/tests/test_cluster.py b/mlxtend/_base/tests/test_cluster.py
|
||||
index 6da1a9d..54c2526 100644
|
||||
--- a/mlxtend/_base/tests/test_cluster.py
|
||||
+++ b/mlxtend/_base/tests/test_cluster.py
|
||||
@@ -51,7 +51,7 @@ def test_check_labels_not_ok_1():
|
||||
|
||||
|
||||
def test_check_labels_integer_notok():
|
||||
- y = np.array([1.0, 2.0], dtype=np.float_)
|
||||
+ y = np.array([1.0, 2.0], dtype=np.float64)
|
||||
cl = BlankClassifier(print_progress=0, random_seed=1)
|
||||
with pytest.raises(AttributeError) as excinfo:
|
||||
cl._check_target_array(y)
|
||||
diff --git a/mlxtend/classifier/multilayerperceptron.py b/mlxtend/classifier/multilayerperceptron.py
|
||||
index 770dab9..05416c3 100644
|
||||
--- a/mlxtend/classifier/multilayerperceptron.py
|
||||
+++ b/mlxtend/classifier/multilayerperceptron.py
|
||||
@@ -143,7 +143,7 @@ class MultiLayerPerceptron(
|
||||
prev_grad_b_out = np.zeros(shape=self.b_["out"].shape)
|
||||
prev_grad_w_out = np.zeros(shape=self.w_["out"].shape)
|
||||
|
||||
- y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float_)
|
||||
+ y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float64)
|
||||
|
||||
self.init_time_ = time()
|
||||
|
||||
diff --git a/mlxtend/classifier/softmax_regression.py b/mlxtend/classifier/softmax_regression.py
|
||||
index 56444e5..173154e 100644
|
||||
--- a/mlxtend/classifier/softmax_regression.py
|
||||
+++ b/mlxtend/classifier/softmax_regression.py
|
||||
@@ -141,7 +141,7 @@ class SoftmaxRegression(_BaseModel, _IterativeModel, _Classifier, _MultiClass):
|
||||
)
|
||||
self.cost_ = []
|
||||
|
||||
- y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float_)
|
||||
+ y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float64)
|
||||
|
||||
self.init_time_ = time()
|
||||
rgen = np.random.RandomState(self.random_seed)
|
||||
diff --git a/mlxtend/math/linalg.py b/mlxtend/math/linalg.py
|
||||
index 02600f1..ece4c3c 100644
|
||||
--- a/mlxtend/math/linalg.py
|
||||
+++ b/mlxtend/math/linalg.py
|
||||
@@ -45,7 +45,7 @@ def vectorspace_orthonormalization(ary, eps=1e-13): # method='gram-schmidt',
|
||||
# 2c) Normalize if linearly independent,
|
||||
# and set to zero otherwise
|
||||
|
||||
- arr = ary.astype(np.float_).copy()
|
||||
+ arr = ary.astype(np.float64).copy()
|
||||
|
||||
for i in range(arr.shape[1]):
|
||||
for j in range(i):
|
||||
diff --git a/mlxtend/plotting/tests/test_decision_regions.py b/mlxtend/plotting/tests/test_decision_regions.py
|
||||
index fba2255..aad63ff 100644
|
||||
--- a/mlxtend/plotting/tests/test_decision_regions.py
|
||||
+++ b/mlxtend/plotting/tests/test_decision_regions.py
|
||||
@@ -94,7 +94,7 @@ def test_y_int_ary():
|
||||
"Try passing the array as y.astype(np.int_)",
|
||||
plot_decision_regions,
|
||||
X[:, :2],
|
||||
- y.astype(np.float_),
|
||||
+ y.astype(np.float64),
|
||||
sr,
|
||||
)
|
||||
|
||||
--
|
||||
2.47.0
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
pytestCheckHook,
|
||||
scipy,
|
||||
numpy,
|
||||
numpy_1,
|
||||
scikit-learn,
|
||||
pandas,
|
||||
matplotlib,
|
||||
@@ -22,7 +23,7 @@ buildPythonPackage rec {
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "rasbt";
|
||||
repo = pname;
|
||||
repo = "mlxtend";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-c6I0dwu4y/Td2G6m2WP/52W4noQUmQMDvpzXA9RZauo=";
|
||||
};
|
||||
@@ -38,10 +39,22 @@ buildPythonPackage rec {
|
||||
joblib
|
||||
];
|
||||
|
||||
patches = [
|
||||
# https://github.com/rasbt/mlxtend/pull/1119
|
||||
./0001-fix-test-replace-np.float_-to-np.float64.patch
|
||||
];
|
||||
|
||||
nativeCheckInputs = [ pytestCheckHook ];
|
||||
|
||||
pytestFlagsArray = [ "-sv" ];
|
||||
|
||||
disabledTests = [
|
||||
# Type changed in numpy2 test should be updated
|
||||
"test_invalid_labels_1"
|
||||
"test_default"
|
||||
"test_nullability"
|
||||
];
|
||||
|
||||
disabledTestPaths = [
|
||||
"mlxtend/evaluate/f_test.py" # need clean
|
||||
"mlxtend/evaluate/tests/test_feature_importance.py" # urlopen error
|
||||
|
||||
Reference in New Issue
Block a user