-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix diffing empty DataTables #1097
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 diffing empty DataTables #1097
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@botandrose Let me know what you think of the changes I suggested, if you disagree we can talk about it.
return ensure_2d(cols.transpose), ensure_2d((matched_cols + unmatched_cols).transpose) | ||
end | ||
|
||
def ensure_2d(array) #:nodoc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should make this method private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already protected
... is that good enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, that's great. I didn't see that.
t1 = DataTable.from([[]]) | ||
t2 = DataTable.from([[]]) | ||
t1.diff!(t2) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use something like
expect{ t1.diff!(t2) }.not_to raise_error
would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically redundant, but more explicitly conveys the intent. I like! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, if you could just change that and push it up I'll merge :) Thanks!
ae1c759
to
cc61811
Compare
Okay! Pushed, and all 💚 here. Thank you for your time and attention! I'll be submitting fixes for one or two more DataTable-related bugs over the coming days, BTW. |
Thank you @botandrose - we really appreciate your help with the project! |
Thanks for handling it @danascheider 👌 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Fixes the following:
See #1096 for much more details.
Details
Added a private
#ensure_2d
method to DataTable, and used it internally in#pad_and_match
to make sure we're always dealing with an array of arrays, which the code had previously been assuming.Motivation and Context
Fixes #1096
How Has This Been Tested?
Added unit test to expose bug, then wrote patch to fix it.
Types of changes
Checklist: