Skip to content

Commit 45d3b7b

Browse files
author
William de Vazelhes
committed
Fix tests by removing duplicates
1 parent 5ea7ba0 commit 45d3b7b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/test_mahalanobis_mixin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,14 @@ def test_transformer_is_2D(estimator, build_dataset):
284284

285285
# test that it works for 1 feature
286286
trunc_data = input_data[..., :1]
287+
# we drop duplicates that might have been formed, i.e. of the form
288+
# aabc or abcc or aabb for quadruplets, and aa for pairs.
289+
slices = {4: [slice(0, 2), slice(2, 4)], 2: [slice(0, 2)]}
290+
if trunc_data.ndim == 3:
291+
for slice_idx in slices[trunc_data.shape[1]]:
292+
_, indices = np.unique(trunc_data[:, slice_idx, :], axis=2,
293+
return_index=True)
294+
trunc_data = trunc_data[indices]
295+
labels = labels[indices]
287296
model.fit(trunc_data, labels)
288297
assert model.transformer_.shape == (1, 1) # the transformer must be 2D

0 commit comments

Comments
 (0)