-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
API: Allow zero length strings to result in zero length dtypes #16825
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
base: main
Are you sure you want to change the base?
Conversation
558e671
to
dd7b901
Compare
Errors exceeded log size :) The following was in an infinite loop...
|
Ah, had not realized this. This one probably requires gh-16817 in that case. |
dd7b901
to
57abaab
Compare
The dtype is of zero length strings is no preserved when creating an array from a scalar in more cases. This also simplifies the `PyArray_FromScalar` code so that the (mainly unused) casting branch reuses `PyArray_Pack` to avoid implementing similar logic multiple times.
57abaab
to
7930b89
Compare
gh-16817 has been merged. @eric-wieser do you still want to review? |
This is ready to merge, correct? |
numpy/core/src/multiarray/ctors.c
Outdated
PyErr_Format(PyExc_RuntimeError, | ||
"dtype changed while creating an array from a python object. " | ||
"This should not be possible. Please notify the NumPy " | ||
"developers you see this message.", | ||
PyArray_DESCR(ret), dtype, PyArray_DESCR(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.
This error format string is missing placeholders.
&PyArray_Type, dtype, ndim, dims, NULL, NULL, | ||
flags&NPY_ARRAY_F_CONTIGUOUS, NULL); | ||
flags&NPY_ARRAY_F_CONTIGUOUS, NULL, NULL, 0, 1); |
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.
As a refresher, what is this 1
argument?
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.
PyArray_NewFromDescr_int(
PyTypeObject *subtype, PyArray_Descr *descr, int nd,
npy_intp const *dims, npy_intp const *strides, void *data,
int flags, PyObject *obj, PyObject *base, int zeroed,
int allow_emptystring)
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@seberg is this meant to be part of the dtype reworking for 1.20 or do we let it slide to a future release? |
Its OK to let this slide, it doesn't really matter when we do this. |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@seberg Needs rebase. |
@seberg needs rebase, then please ping reviewers |
@seberg this needs a rebase |
The dtype is of zero length strings is no preserved when creating
an array from a scalar in more cases.
This also simplifies the
PyArray_FromScalar
code so that the(mainly unused) casting branch reuses
PyArray_Pack
to avoidimplementing similar logic multiple times.