Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix, document, and test ColumnType.compare and Table.compareRows #1266

Merged
merged 3 commits into from
Jan 8, 2025

Conversation

ccleva
Copy link
Contributor

@ccleva ccleva commented Jan 2, 2025

Thanks for contributing.

Description

  • ColumnType.compare now compares rows at the same rownumber instead of comparing with the last row of the other column
  • Table.compareRows now returns false if the number of columns is different in both tables
  • Added missing javadoc on both methods

Fixes #1229

Testing

Yes, let me know if you want them moved to an existing test class

core/src/main/java/tech/tablesaw/api/ColumnType.java Outdated Show resolved Hide resolved
core/src/main/java/tech/tablesaw/api/ColumnType.java Outdated Show resolved Hide resolved
core/src/main/java/tech/tablesaw/api/Table.java Outdated Show resolved Hide resolved
core/src/main/java/tech/tablesaw/api/ColumnType.java Outdated Show resolved Hide resolved
core/src/main/java/tech/tablesaw/api/Table.java Outdated Show resolved Hide resolved
core/src/main/java/tech/tablesaw/api/Table.java Outdated Show resolved Hide resolved
core/src/main/java/tech/tablesaw/api/Table.java Outdated Show resolved Hide resolved
@ccleva ccleva force-pushed the fix_table_comparerows branch from 73c9c25 to 46445a3 Compare January 3, 2025 15:30
@ccleva
Copy link
Contributor Author

ccleva commented Jan 3, 2025

All conversation should be fixed. I rebased the branch also in case

@benmccann
Copy link
Collaborator

Can you rebase this PR again to make sure the formatter runs against it now that the formatter's been fixed?

@ccleva
Copy link
Contributor Author

ccleva commented Jan 3, 2025

I'm unable to make the formatter working for the moment

@benmccann
Copy link
Collaborator

@ccleva could you try rebasing and formatting now that you've gotten the formatter working?

@ccleva ccleva force-pushed the fix_table_comparerows branch from 46445a3 to 92fdb67 Compare January 7, 2025 16:56
@ccleva
Copy link
Contributor Author

ccleva commented Jan 7, 2025

@ccleva could you try rebasing and formatting now that you've gotten the formatter working?

Yes, I rebased then ran the hook manually

* Compares the row at {@code rowNumber} in {@code column1} and {@code column2} and returns whether they are equal.
* @throws {@code IndexOutOfBoundsException} if {@code rowNumber} exceeds either column size
*/
default boolean compare(int rowNumber, Column<?> column1, Column<?> column2) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels like kind of a weird method honestly. I wonder if we even need it to be a standalone method or if we can just inline it into compareRows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be used by people for other purposes. No harm in keeping it I think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're changing the functioning of it pretty drastically. Anyone who is relying on it is going to be broken. Better for them to find that out at compile-time because we removed it than at runtime

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, this one was broken in the previous version anyway, good point. Will change as you suggest

@ccleva ccleva force-pushed the fix_table_comparerows branch from 92fdb67 to 90c3083 Compare January 8, 2025 08:49
@benmccann benmccann merged commit 7a716f2 into jtablesaw:master Jan 8, 2025
7 checks passed
@ccleva ccleva deleted the fix_table_comparerows branch January 10, 2025 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table.compareRows not working as expected
2 participants