-
Notifications
You must be signed in to change notification settings - Fork 653
Closed
Labels
Description
I encountered an issue that seems to be related to #586. However, #586 was marked as closed in August 2019, and I'm experiencing this issue using the latest 0.37.3 jar from Maven Central.
The issue is when .sortAscending is called on a DoubleColumn produced by a call to .unique, the result is all 0s.
I created a short, simple example that illustrates the issue:
double[] ds = { 5, 4, 3, 2, 1, 5, 4, 3, 2, 1 };
DoubleColumn unq = DoubleColumn.create("All 0s", ds).unique();
System.out.println(Arrays.toString(unq.asDoubleArray()));
unq.sortAscending();
System.out.println(Arrays.toString(unq.asDoubleArray()));
System.out.println();
// Must make a copy here, otherwise sorting will expand with 0s.
unq = DoubleColumn.create("All 0s", ds).unique().copy();
System.out.println(Arrays.toString(unq.asDoubleArray()));
unq.sortAscending();
System.out.println(Arrays.toString(unq.asDoubleArray()));
The output from running this is:
[1.0, 4.0, 3.0, 5.0, 2.0]
[0.0, 0.0, 0.0, 0.0, 0.0]
[1.0, 4.0, 3.0, 5.0, 2.0]
[1.0, 2.0, 3.0, 4.0, 5.0]
As featured in the example code, it's possible to work around the issue by calling .copy on the DoubleColumn produced by the call to .unique.