-
-
Notifications
You must be signed in to change notification settings - Fork 11k
BUG: Fix object scalar return type of 0-d array indices #4109
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
BUG: Fix object scalar return type of 0-d array indices #4109
Conversation
return PyArray_Return((PyArrayObject *)ret); | ||
} | ||
return ret; | ||
} |
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.
Actually the only thing that block does is probably should be to more or less correctly support arr['0', '0']
or broken types, and my new stuff doesn't have that yet... (something like this was probably historically always there)
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.
Indentation of '}' ?
BUG: Fix object scalar return type of 0-d array indices http://stackoverflow.com/questions/20409334/subclassed-empty-numpy-recarray-losing-its-type-and-added-attributes-in-numpy-1
return array_subscript_fancy(self, op, fancy); | ||
} | ||
PyObject *ret; | ||
8000 ret = array_subscript_fancy(self, op, fancy); |
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.
This line might look better if it were swapped with the following blank line.
Looks good modulo style nitpicks. I'm relying on the tests to check that the code does what is claimed ;) |
PyArray_Result was called when it should not have been. This caused object arrays of 0-d arrays have the inner array converted to a scalar: `np.array([np.array(0), None])[0] -> np._float(0)` The same case happened to recarray field access when indexing more than one field. This fixes it.
Good, luckily, all cases which should not result in an array go normally through their own special case, so I don't think I can break anything ;). Fixed the style nitpicks, but want confirmation that fixing |
BUG: Fix object scalar return type of 0-d array indices
I admit, master currently doesn't, I opened a 1.9. blocker about it though. My indexing stuff does mostly (except for the one corner case at this time). |
this fix breaks pandas 0.13, you get lots of test failures of these types:
the fix is also in the 1.8.x branch so pandas is also broken there whih must be accounted for should a 1.8.1 be made |
as pointed out in the pandas issue the maintenance branch is broken by this:
surprising we don't have a test for this. @seberg do you have time too look at this or should we just revert it for now? |
Oh, I think I will fix it soon. Just need to look through the subtleties and best check what 1.7 did. A mostly fix is simple in any case and quite right may be impossible, but it should match 1.7. if possible... |
@juliantaylor, see gh-4223. |
PyArray_Result was called when it should not have been. This caused
object arrays of 0-d arrays have the inner array converted to a
scalar:
np.array([np.array(0), None])[0] -> np._float(0)
The same case happened to recarray field access. This fixes it.
(This was an SO question, maybe it will be an issue here, too... It is a regression in 1.8.x). There are some code blocks there I am sure are not used, but I don't want to touch the old mapping.c more then absolutely necessary... My current plan is, that when this is merged I create a blocker issue for 1.9.x. My indexing branch has it fixed anyway, I know that is not the right procedure, so if someone disagrees...