Skip to content

Commit

Permalink
Merge pull request #115 from shapelets/fix/findBestNOccurrencesIndexes
Browse files Browse the repository at this point in the history
Fix issue with findNBestOccurrences indexes array type
  • Loading branch information
jrecuerda authored Jun 6, 2019
2 parents cf7836a + db3ed71 commit 0b4bf98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/khiva/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void findBestNOccurrences(af::array q, af::array t, long n, af::array &distances

af::sort(sortedDistances, sortedIndexes, distancesGlobal);

indexes = sortedIndexes(af::seq(n), af::span, af::span).as(t.type());
indexes = sortedIndexes(af::seq(n), af::span, af::span);
distances = sortedDistances(af::seq(n), af::span, af::span).as(t.type());
}

Expand Down
7 changes: 2 additions & 5 deletions test/matrixTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,10 @@ void findBestNOccurrences() {
ASSERT_EQ(distance.dims(), af::dim4(1, 1, 2, 1));
ASSERT_EQ(index.dims(), af::dim4(1, 1, 2, 1));

distance = distance.as(f32);
index = index.as(s64);

ASSERT_NEAR(distance(0, 0, 0, 0).scalar<float>(), expectedDistance, 1e-2);
ASSERT_NEAR(distance(0, 0, 1, 0).scalar<float>(), expectedDistance, 1e-2);
ASSERT_EQ(index(0, 0, 0, 0).scalar<long long>(), expectedIndex);
ASSERT_EQ(index(0, 0, 0, 0).scalar<long long>(), expectedIndex);
ASSERT_EQ(index(0, 0, 0, 0).scalar<unsigned int>(), expectedIndex);
ASSERT_EQ(index(0, 0, 1, 0).scalar<unsigned int>(), expectedIndex);
}

void findBestNOccurrencesMultipleQueries() {
Expand Down

0 comments on commit 0b4bf98

Please sign in to comment.