Skip to content

Commit 8583df4

Browse files
authored
Fix 5 test regarding make_spd_matrix usage from sklearn (#321)
* Add venv to gitignore * Fix 5 test regarding make_spd_matrix usage from sklearn
1 parent 137880d commit 8583df4

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ htmlcov/
77
.cache/
88
.pytest_cache/
99
doc/auto_examples/*
10-
doc/generated/*
10+
doc/generated/*
11+
venv/

test/metric_learn_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def test_singleton_class(self):
929929
X = X[[ind_0[0], ind_1[0], ind_2[0]]]
930930
y = y[[ind_0[0], ind_1[0], ind_2[0]]]
931931

932-
A = make_spd_matrix(X.shape[1], X.shape[1])
932+
A = make_spd_matrix(n_dim=X.shape[1], random_state=X.shape[1])
933933
nca = NCA(init=A, max_iter=30, n_components=X.shape[1])
934934
nca.fit(X, y)
935935
assert_array_equal(nca.components_, A)
@@ -940,7 +940,7 @@ def test_one_class(self):
940940
X = self.iris_points[self.iris_labels == 0]
941941
y = self.iris_labels[self.iris_labels == 0]
942942

943-
A = make_spd_matrix(X.shape[1], X.shape[1])
943+
A = make_spd_matrix(n_dim=X.shape[1], random_state=X.shape[1])
944944
nca = NCA(init=A, max_iter=30, n_components=X.shape[1])
945945
nca.fit(X, y)
946946
assert_array_equal(nca.components_, A)

test/test_mahalanobis_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ def test_init_mahalanobis(estimator, build_dataset):
503503
model.fit(input_data, labels)
504504

505505
# Initialize with a random spd matrix
506-
init = make_spd_matrix(X.shape[1], random_state=rng)
506+
init = make_spd_matrix(n_dim=X.shape[1], random_state=rng)
507507
model.set_params(**{param: init})
508508
model.fit(input_data, labels)
509509

510510
# init.shape[1] must match X.shape[1]
511-
init = make_spd_matrix(X.shape[1] + 1, X.shape[1] + 1)
511+
init = make_spd_matrix(n_dim=X.shape[1] + 1, random_state=rng)
512512
model.set_params(**{param: init})
513513
msg = ('The input dimensionality {} of the given '
514514
'mahalanobis matrix `{}` must match the '

0 commit comments

Comments
 (0)