at 25.11-pre 109 lines 4.5 kB view raw
1From 360cb75317aecaf6b9abcf24f0577afef75c464e Mon Sep 17 00:00:00 2001 2From: wxt <3264117476@qq.com> 3Date: Mon, 6 Jan 2025 20:41:27 +0800 4Subject: [PATCH] fix(test): replace np.float_ to np.float64 5 6--- 7 mlxtend/_base/_regressor.py | 2 +- 8 mlxtend/_base/tests/test_classifier.py | 2 +- 9 mlxtend/_base/tests/test_cluster.py | 2 +- 10 mlxtend/classifier/multilayerperceptron.py | 2 +- 11 mlxtend/classifier/softmax_regression.py | 2 +- 12 mlxtend/math/linalg.py | 2 +- 13 mlxtend/plotting/tests/test_decision_regions.py | 2 +- 14 7 files changed, 7 insertions(+), 7 deletions(-) 15 16diff --git a/mlxtend/_base/_regressor.py b/mlxtend/_base/_regressor.py 17index e3d0a1d..1d3a5d6 100644 18--- a/mlxtend/_base/_regressor.py 19+++ b/mlxtend/_base/_regressor.py 20@@ -16,7 +16,7 @@ class _Regressor(object): 21 pass 22 23 def _check_target_array(self, y, allowed=None): 24- if not isinstance(y[0], (float, np.float_)): 25+ if not isinstance(y[0], (float, np.float64)): 26 raise AttributeError("y must be a float array.\nFound %s" % y.dtype) 27 28 def fit(self, X, y, init_params=True): 29diff --git a/mlxtend/_base/tests/test_classifier.py b/mlxtend/_base/tests/test_classifier.py 30index f77f74d..1bbac6d 100644 31--- a/mlxtend/_base/tests/test_classifier.py 32+++ b/mlxtend/_base/tests/test_classifier.py 33@@ -51,7 +51,7 @@ def test_check_labels_not_ok_1(): 34 35 36 def test_check_labels_integer_notok(): 37- y = np.array([1.0, 2.0], dtype=np.float_) 38+ y = np.array([1.0, 2.0], dtype=np.float64) 39 cl = BlankClassifier(print_progress=0, random_seed=1) 40 with pytest.raises(AttributeError) as excinfo: 41 cl._check_target_array(y) 42diff --git a/mlxtend/_base/tests/test_cluster.py b/mlxtend/_base/tests/test_cluster.py 43index 6da1a9d..54c2526 100644 44--- a/mlxtend/_base/tests/test_cluster.py 45+++ b/mlxtend/_base/tests/test_cluster.py 46@@ -51,7 +51,7 @@ def test_check_labels_not_ok_1(): 47 48 49 def test_check_labels_integer_notok(): 50- y = np.array([1.0, 2.0], dtype=np.float_) 51+ y = np.array([1.0, 2.0], dtype=np.float64) 52 cl = BlankClassifier(print_progress=0, random_seed=1) 53 with pytest.raises(AttributeError) as excinfo: 54 cl._check_target_array(y) 55diff --git a/mlxtend/classifier/multilayerperceptron.py b/mlxtend/classifier/multilayerperceptron.py 56index 770dab9..05416c3 100644 57--- a/mlxtend/classifier/multilayerperceptron.py 58+++ b/mlxtend/classifier/multilayerperceptron.py 59@@ -143,7 +143,7 @@ class MultiLayerPerceptron( 60 prev_grad_b_out = np.zeros(shape=self.b_["out"].shape) 61 prev_grad_w_out = np.zeros(shape=self.w_["out"].shape) 62 63- y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float_) 64+ y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float64) 65 66 self.init_time_ = time() 67 68diff --git a/mlxtend/classifier/softmax_regression.py b/mlxtend/classifier/softmax_regression.py 69index 56444e5..173154e 100644 70--- a/mlxtend/classifier/softmax_regression.py 71+++ b/mlxtend/classifier/softmax_regression.py 72@@ -141,7 +141,7 @@ class SoftmaxRegression(_BaseModel, _IterativeModel, _Classifier, _MultiClass): 73 ) 74 self.cost_ = [] 75 76- y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float_) 77+ y_enc = self._one_hot(y=y, n_labels=self.n_classes, dtype=np.float64) 78 79 self.init_time_ = time() 80 rgen = np.random.RandomState(self.random_seed) 81diff --git a/mlxtend/math/linalg.py b/mlxtend/math/linalg.py 82index 02600f1..ece4c3c 100644 83--- a/mlxtend/math/linalg.py 84+++ b/mlxtend/math/linalg.py 85@@ -45,7 +45,7 @@ def vectorspace_orthonormalization(ary, eps=1e-13): # method='gram-schmidt', 86 # 2c) Normalize if linearly independent, 87 # and set to zero otherwise 88 89- arr = ary.astype(np.float_).copy() 90+ arr = ary.astype(np.float64).copy() 91 92 for i in range(arr.shape[1]): 93 for j in range(i): 94diff --git a/mlxtend/plotting/tests/test_decision_regions.py b/mlxtend/plotting/tests/test_decision_regions.py 95index fba2255..aad63ff 100644 96--- a/mlxtend/plotting/tests/test_decision_regions.py 97+++ b/mlxtend/plotting/tests/test_decision_regions.py 98@@ -94,7 +94,7 @@ def test_y_int_ary(): 99 "Try passing the array as y.astype(np.int_)", 100 plot_decision_regions, 101 X[:, :2], 102- y.astype(np.float_), 103+ y.astype(np.float64), 104 sr, 105 ) 106 107-- 1082.47.0 109