8000 API: Allow zero length strings to result in zero length dtypes by seberg · Pull Request #16825 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

seberg
Copy link
Member
@seberg seberg commented Jul 12, 2020

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.

@seberg seberg force-pushed the simplify-scalar-asarray branch from 558e671 to dd7b901 Compare July 12, 2020 20:58
@charris
Copy link
Member
charris commented Jul 13, 2020

Errors exceeded log size :) The following was in an infinite loop...

DeprecationWarning: elementwise comparison failed; this will raise an error in the future.

The above exception was the direct cause of the following exception:

@eric-wieser eric-wieser self-requested a review July 13, 2020 10:06
@seberg
Copy link
Member Author
seberg commented Jul 13, 2020

Ah, had not realized this. This one probably requires gh-16817 in that case.

@seberg seberg force-pushed the simplify-scalar-asarray branch from dd7b901 to 57abaab Compare July 13, 2020 15:31
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.
@seberg seberg force-pushed the simplify-scalar-asarray branch from 57abaab to 7930b89 Compare July 13, 2020 16:31
@mattip
Copy link
Member
mattip commented Aug 2, 2020

gh-16817 has been merged. @eric-wieser do you still want to review?

@mattip
Copy link
Member
mattip commented Aug 13, 2020

This is ready to merge, correct?

Comment on lines 1482 to 1486
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));
Copy link
Member

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);
Copy link
Member

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?

Copy link
Member

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>
@mattip
Copy link
Member
mattip commented Nov 12, 2020

@seberg is this meant to be part of the dtype reworking for 1.20 or do we let it slide to a future release?

@seberg
Copy link
Member Author
seberg commented Nov 12, 2020

Its OK to let this slide, it doesn't really matter when we do this.

Base automatically changed from master to main March 4, 2021 02:04
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@charris
Copy link
Member
charris commented Apr 21, 2021

@seberg Needs rebase.

@mattip
Copy link
Member
mattip commented May 16, 2021

@seberg needs rebase, then please ping reviewers

@mattip
Copy link
Member
mattip commented Jul 1, 2021

@seberg this needs a rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0