-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
CLN: More numpy 2 stuff #57668
CLN: More numpy 2 stuff #57668
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.
nice work
@@ -492,7 +490,7 @@ static int NpyArr_iterNextItem(JSOBJ obj, JSONTypeContext *tc) { | |||
((PyObjectEncoder *)tc->encoder)->npyValue = npyarr->dataptr; | |||
((PyObjectEncoder *)tc->encoder)->npyCtxtPassthru = npyarr; | |||
} else { | |||
GET_TC(tc)->itemValue = npyarr->getitem(npyarr->dataptr, npyarr->array); | |||
GET_TC(tc)->itemValue = PyArray_GETITEM(npyarr->array, npyarr->dataptr); |
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.
The failing build doesn't like the implicit conversion from a PyArrayObject* to a PyObject* . Should be able to type-check / cast to make the compiler happy
@@ -492,7 +490,8 @@ static int NpyArr_iterNextItem(JSOBJ obj, JSONTypeContext *tc) { | |||
((PyObjectEncoder *)tc->encoder)->npyValue = npyarr->dataptr; | |||
((PyObjectEncoder *)tc->encoder)->npyCtxtPassthru = npyarr; | |||
} else { | |||
GET_TC(tc)->itemValue = npyarr->getitem(npyarr->dataptr, npyarr->array); | |||
GET_TC(tc)->itemValue = | |||
PyArray_GETITEM((PyArrayObject *)npyarr->array, npyarr->dataptr); |
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.
Would still prefer a type check before the cast - prevents strange bugs in case this ever gets refactored.
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.
Looks like it already happens a couple lines above.
pandas/pandas/_libs/src/vendored/ujson/python/objToJSON.c
Lines 477 to 480 in e14a9bd
if (!PyArray_Check(npyarr->array)) { | |
PyErr_SetString(PyExc_TypeError, | |
"NpyArr_iterNextItem received a non-array object"); | |
return 0; |
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.
In that case we should assign const PyArrayObject *arrayobj = (const PyArrayObject *)npyarr->array
right after the type check and reference that here.
Generally want to minimize casting and keep it very localized to where the type check happens (historically we have not done a good job of this) Otherwise things are very liable to break when refactoring
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.
lgtm. didn't look through all failures but assume they are leap day issues. maybe worth waiting until tomorrow
I merged main thinking the CI failures would be gone by now but looks like they are still around. Happy to merge as is given I am fairly confident the failures are unrelated, but will leave it up to you |
Merging then, since numpy is blocked on this. Thanks for the review! |
Backport PR #57668: CLN: More numpy 2 stuff Co-authored-by: Thomas Li <47963215+lithomas1@users.noreply.github.com>
* CLN: More numpy 2 stuff * More * fix warning * clean --------- Co-authored-by: William Ayd <will_ayd@innobi.io>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.