Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Gh 36562 typeerror comparison not supported between float and str #37096
Gh 36562 typeerror comparison not supported between float and str #37096
Changes from 4 commits
1320ff1
a1b9385
1f76d21
7076841
225675d
2677166
6f476bc
3688238
aba429c
8ae9279
dd5a38d
7b7d6f8
4226662
8cbfa01
6d71000
92e1e33
3ada9ce
95670f1
d9dcd22
66c30c7
db66528
16ae4f4
9d03dc3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
can you simply try to remove the nan's from values and add them to the end is fine and just fix up sort_mixed, we do this in a number of places e.g. something 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.
I started off with trying to fix
sort_mixed
and removed nans as you suggested and would have loved to use it instead. however the structure of the array doesn't allow for that (we are talking about a 1-d array of tuples, i.e. dtype object, not an N-d array which would allow for all those vector operations to be applicable).here's the data of
values
that gets passed in tosort_tuples()
when running the test I added:I could convert
value
to a N-d array (and usesort_mixed
), but that solution would come with its own overhead costs...your call.
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.
any feedback on the above, @jreback?
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 care about code complexity here, this is adding a lot, try this
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.
could do
cmp_func(left, right)
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.
yes let's change the name and please add typing for cmp_func and sort_tuples. (sort_mixed if you can as well :->)
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 wouldn't explicitly assign these, just use them directly whenever they're needed
it's an O(1) lookup so this doesn't save any time but makes code a bit more verbose
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.
generally speaking I wonder if the control flow can be simplified a bit here. you have a number of ifs but only two possible outputs
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.
3 outcomes (=,<,>), but in combination with nan, they increase.
there are 9 ifs of which 2 are not relevant (shortcut before the loop, fall-though after the loop).
7 ifs remaining:
I could merge some of the cases (with same return value), but that would compromise readability and require nan checks to be done earlier.
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.
x_is_na
andy_is_na
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.
why do we need
(x_i_na and y_i_na)
? Could one of them be null?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.
equality check - both of the values are the same (both na or both the same non-na value).
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.
could do this before checking for equality?
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'd say no need to comment about consistency with numpy in the code (but thanks for noting it here!)
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.
sure, but why?
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 would skip this comment.
In general we don't leave references to issues in the code, git/blame keeps track of that
You have a comment upstairs in sort_tuples that explains what it does so I think no need to repeat here
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.
For floating point equality use
assert_almost_equal(res, expected)