Skip to content

Commit 4b0bae9

Browse files
author
William de Vazelhes
committed
FIX: update code to work with old version of numpy that does not have axis for unique
1 parent dbf5257 commit 4b0bae9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/test_mahalanobis_mixin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,10 @@ def test_transformer_is_2D(estimator, build_dataset):
288288
slices = {4: [slice(0, 2), slice(2, 4)], 2: [slice(0, 2)]}
289289
if trunc_data.ndim == 3:
290290
for slice_idx in slices[trunc_data.shape[1]]:
291-
_, indices = np.unique(trunc_data[:, slice_idx, :], axis=2,
292-
return_index=True)
293-
trunc_data = trunc_data[indices]
294-
labels = labels[indices]
291+
pairs = trunc_data[:, slice_idx, :]
292+
diffs = pairs[:, 1, :] - pairs[:, 0, :]
293+
to_keep = np.nonzero(diffs.ravel())
294+
trunc_data = trunc_data[to_keep]
295+
labels = labels[to_keep]
295296
model.fit(trunc_data, labels)
296297
assert model.transformer_.shape == (1, 1) # the transformer must be 2D

0 commit comments

Comments
 (0)