Skip to content

BUG: raise error for erroneous structured array assignment - #4556

Closed
mbyt wants to merge 3 commits into
numpy:masterfrom
mbyt:gh_3126
Closed

mbyt wants to merge 3 commits into
numpy:masterfrom
mbyt:gh_3126

Conversation

@mbyt

@mbyt mbyt commented Mar 26, 2014

Copy link
Copy Markdown
Contributor

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

charris commented Mar 27, 2014

Copy link
Copy Markdown
Member

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

mbyt commented Mar 30, 2014

Copy link
Copy Markdown
Contributor Author

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

charris commented Mar 30, 2014

Copy link
Copy Markdown
Member

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

@charris

charris commented Mar 30, 2014

Copy link
Copy Markdown
Member

I left a note at #3126.

@mbyt

mbyt commented Apr 30, 2014

Copy link
Copy Markdown
Contributor Author

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

@mbyt

mbyt commented Dec 29, 2014

Copy link
Copy Markdown
Contributor Author

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

@mbyt

mbyt commented Feb 3, 2015

Copy link
Copy Markdown
Contributor Author

I left a not in #3126.

@charris

charris commented Jun 4, 2015

Copy link
Copy Markdown
Member

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

@charris

charris commented Jun 10, 2015

Copy link
Copy Markdown
Member

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