10000 BUG: raise error for erroneous structured array assignment by mbyt · Pull Request #4556 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: raise error for erroneous structured array assignment #4556

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
wants to merge 3 commits into from

Conversation

mbyt
Copy link
Contributor
@mbyt mbyt commented Mar 26, 2014

This pull request shows one possible way how to resolve #3126 and #3561: It just raises an error for non supported / erroneous operations.

import numpy as np
print np.__version__

x = np.empty(1, dtype=[('field', 'i4', 10)])
ones = np.ones(10, dtype='i4')

# OK
x[:]['field'] = 1 * ones     # array_assign_subscript
print x
x['field'] = 2 * ones        # array_assign_subscript
print x
x[0]['field'][:] = 3 * ones  # array_assign_slice
print x

# FAIL (only first item is assigned)
x[0]['field'] = 4 * ones     # voidtype_ass_subscript 
print x

However, it might be much nicer to actually assign the call correctly (I did not manage to do this, therefore I just raise an error). The above code lines show 4 operations how to assign the same field with their C function call as comment. Note that only the call to voidtype_ass_subscript fails.

python -c "import numpy; numpy.test()" run OK.

@mbyt mbyt changed the title BUG: Raise error for non supported structured array assignment BUG: raise error for erroneous structured array assignment Mar 26, 2014
@charris
Copy link
Member
charris commented Mar 27, 2014

There seems to be a Python 3 related bug somewhere, and Python 2.6 is failing also. But 2.7 works :)

The commit messages should begin with one of the prefixes in doc/source/dev/gitwash/development_workflow.rst

Raising an error for non supported operations. Also adapting related
statement in test. Resolves numpy#3126 and numpy#3561.
@mbyt
Copy link
Contributor Author
mbyt commented Mar 30, 2014

OK, good point. I resolved the 3.3 and 2.6 problems. In order to get the commit messages right, I squashed the commits in a rebase and forced a push.

@charris
Copy link
Member
charris commented Mar 30, 2014

You did the right thing, the tests are running now. Sometimes it takes a while and sometimes travis is just not behaving.

8000
@charris
Copy link
Member
charris commented Mar 30, 2014

I left a note at #3126.

@mbyt
Copy link
Contributor Author
mbyt commented Apr 30, 2014

I also left a note in #3126, how can we proceed?

@mbyt
Copy link
Contributor Author
mbyt commented Dec 29, 2014

I left a note in #3126 --- is there something that can be done to get this moving along?

@mbyt
Copy link
Contributor Author
mbyt commented Feb 3, 2015

I left a not in #3126.

@charris
Copy link
Member
charris commented Jun 4, 2015

Looks like we are going to have a better fix for this issue, but it isn't in yet.

@charris
Copy link
Member
charris commented Jun 10, 2015

Thanks @mbyt for the PR. I'm going to go with #5947 for this problem, so closing.

@charris charris closed this Jun 10, 2015
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.

Inconsistent array assignment for structured arrays
3 participants
0