Skip to content

Commit

Permalink
Fix TopNTreeMap test
Browse files Browse the repository at this point in the history
  • Loading branch information
maurever committed Nov 21, 2024
1 parent 9392d15 commit c9142a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 0 additions & 6 deletions h2o-algos/src/main/java/hex/knn/KNNKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ public int hashCode() {
}

@Override
/**
* The compare method does not ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all cases:
* in case the this.value and o.value are the same but the keys are not same -> order of asking matters.
* In this special case x.compareTo(y) == y.compareTo(x).
* We need this functionality for ordering in TopNTreeMap, where order of asking is important to decide top N neighbours.
*/
public int compareTo(KNNKey<K, V> o) {
if (o == null) return 1;
int sameValue = this.value.compareTo(o.value);
Expand Down
4 changes: 2 additions & 2 deletions h2o-algos/src/test/java/hex/knn/TopNTreeMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void testKNNKeyCompareTo(){
// same key same value -> both object are the same
Assert.assertEquals(k2.compareTo(k3), 0);

// different key same value -> the first is less
Assert.assertEquals(k2.compareTo(k1), -1);
// different key same value -> depends on key comparator
Assert.assertEquals(k2.compareTo(k1), 1);

// same key different value -> the item with less value is less
Assert.assertEquals(k3.compareTo(k4), -1);
Expand Down

0 comments on commit c9142a1

Please sign in to comment.