Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stumpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3947,7 +3947,7 @@ def _subspace(D, k, include=None, discords=False):
that `k+1` rows will be returned.
"""
if discords:
sorted_idx = D[::-1].argsort(axis=0, kind="mergesort")
sorted_idx = (-D).argsort(axis=0, kind="mergesort")
else:
sorted_idx = D.argsort(axis=0, kind="mergesort")

Expand Down
4 changes: 2 additions & 2 deletions tests/naive.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def subspace(T, m, subseq_idx, nn_idx, k, include=None, discords=False):
)

if discords:
sorted_idx = D[::-1].argsort(axis=0, kind="mergesort")
sorted_idx = (-D).argsort(axis=0, kind="mergesort")
else:
sorted_idx = D.argsort(axis=0, kind="mergesort")

Expand Down Expand Up @@ -748,7 +748,7 @@ def maamp_subspace(T, m, subseq_idx, nn_idx, k, include=None, discords=False, p=
)

if discords:
sorted_idx = D[::-1].argsort(axis=0, kind="mergesort")
sorted_idx = (-D).argsort(axis=0, kind="mergesort")
else:
sorted_idx = D.argsort(axis=0, kind="mergesort")

Expand Down
9 changes: 9 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,15 @@ def test_select_P_ABBA_val_inf():
npt.assert_allclose(cmp, ref, atol=1.5e-07)


def test_subspace_discords():
D = np.array([1.0, 3.0, 2.0])
ref = np.array([1, 2, 0])

for k in range(D.shape[0]):
cmp = core._subspace(D, k, discords=True)
npt.assert_array_equal(cmp, ref[: k + 1])


def test_merge_topk_PI_without_overlap():
# This is to test function `core._merge_topk_PI(PA, PB, IA, IB)` when there
# is no overlap between row IA[i] and row IB[i].
Expand Down
Loading