8000 _dtype_from_pep3118 is non-deterministic given zero-sized elements · Issue #9053 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

_dtype_from_pep3118 is non-deterministic given zero-sized elements #9053

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

Closed
bmerry opened this issue May 5, 2017 · 1 comment
Closed

_dtype_from_pep3118 is non-deterministic given zero-sized elements #9053

bmerry opened this issue May 5, 2017 · 1 comment

Comments

@bmerry
Copy link
Contributor
bmerry commented May 5, 2017

In numpy 1.12.1, this code gives non-deterministic results, I'm guessing because the original field order is not preserved (the fields local variable is a dict rather than an OrderedDict):

>>> print(np.core._internal._dtype_from_pep3118("(0)I:a:f:f:"))

In some cases the output is [('a', '<u4', (0,)), ('f', '<f4')], in others it is {'names':['f','a'], 'formats':['<f4',('<u4', (0,))], 'offsets':[0,0], 'itemsize':4}.

These dtypes are at least equal to each other, but it gets worse: given f:f:(0)Iempty:4x, the padding is sometimes anonymous, and sometimes a field called pad0. These dtypes aren't the same and can't be cast between each other with the 'safe' or 'equiv' rules.

@eric-wieser
Copy link
Member

Thanks for the report. Combined with #9049, it seems like perhaps the function should just be thrown out and rewritten

I've made a start on a patch, and got as far as some cleanup - but am struggling to understand the padding rules, since the only specification I can find is the implementation

eric-wies 8000 er added a commit to eric-wieser/numpy that referenced this issue May 5, 2017
Adding padding fields means that dtypes with the same fields cannot necessarily
be cast to one another. Padding shouldn't prevent casting.

Partially fixes numpy#9053
mherkazandjian pushed a commit to mherkazandjian/numpy that referenced this issue May 30, 2017
Adding padding fields means that dtypes with the same fields cannot necessarily
be cast to one another. Padding shouldn't prevent casting.

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

No branches or pull requests

2 participants
0