Skip to content

BUG: argmin/max of object dtype with NULLs, fixes #6032#6236

Merged
charris merged 1 commit intonumpy:masterfrom
jaimefrio:argminmax_object
Aug 28, 2015
Merged

BUG: argmin/max of object dtype with NULLs, fixes #6032#6236
charris merged 1 commit intonumpy:masterfrom
jaimefrio:argminmax_object

Conversation

@jaimefrio
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks equivalent to i == n.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

They way figured, if all entries are NULL, then at the end i == n and mp == NULL, but if the last entry is the first non-NULL, then at the end i == n but mp != NULL. It is probably a good idea to add test cases with both these situations.

@jaimefrio jaimefrio force-pushed the argminmax_object branch 2 times, most recently from 8198e4e to c606498 Compare August 23, 2015 00:07
@jaimefrio
Copy link
Copy Markdown
Member Author

I just realized we are happily assuming that the object comparison will never fail, which we know is not always the case, especially in Python 3. Added a check to exit on first failure. And I also followed your suggestion for skipping over the NULLs, although I simplified it further by not special casing the first item.

@charris
Copy link
Copy Markdown
Member

charris commented Aug 23, 2015

LGTM. I'd probably have bailed early on all NULL, but there is always more than one way ;) Is there any error return from these function that might be appropriate for a comparison error? Oh, and IIRC, richcompare is available in all supported Python versions and falls back to cmp in Python 2 if only cmp is available. I wonder if we should stop using the fallback compare? Might be something we need to pass by the list, but it might also provide more consistent behavior for Python 2 and 3.

@jaimefrio
Copy link
Copy Markdown
Member Author

Yup, 2.6 has it, and so does my latest commit.

@charris
Copy link
Copy Markdown
Member

charris commented Aug 23, 2015

Should probably mention in release notes under Compatibility Notes just in case this changes behavior for somebody.

charris added a commit that referenced this pull request Aug 28, 2015
BUG: argmin/max of object dtype with NULLs, fixes #6032
@charris charris merged commit 2e9bd3f into numpy:master Aug 28, 2015
@charris
Copy link
Copy Markdown
Member

charris commented Aug 28, 2015

Thanks Jaime. I'm going to update the 1.11 notes anyway and will mention this.

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.

2 participants