jtablesaw / tablesaw

Java dataframe and visualization library
https://jtablesaw.github.io/tablesaw/
Apache License 2.0
3.56k stars 645 forks source link

isIn(Collection) not matching Integers #1227

Open m37r opened 1 year ago

m37r commented 1 year ago

For a given IntColumn, only the isIn(int...) method produces the expected results. The isIn(Collection) method inherited from NumericColumn matches actually contained numbers only when they are entered as Doubles into the query collection.

To test:

IntColumn column = IntColumn.create("c", 1, 2);
assertEquals(1, column.isIn(1).size()); // passes
assertEquals(1, column.isIn(Arrays.asList(1d)).size()); // passes
assertEquals(1, column.isIn(Arrays.asList(1)).size()); // fails

I think this is due to NumericColumn.isIn(Collection) using Collection.contains for matching against Double-converted content cells. I might even produce a fix.