Skip to content

BUG: do not change size 0 description when viewing data - #8971

Merged
charris merged 1 commit into
numpy:masterfrom
juliantaylor:uninitialized-empty
Apr 23, 2017
Merged

charris merged 1 commit into
numpy:masterfrom
juliantaylor:uninitialized-empty

Conversation

@juliantaylor

@juliantaylor juliantaylor commented Apr 21, 2017 •

Copy link
Copy Markdown
Contributor

If the array being viewed is a zero sized array, e.g. 'S0' from
structured types, do not change the description to itemsize 1 as this
would expose uninitialized data, e.g. in
TestStructured.test_zero_width_string

See also #6430

@eric-wieser

eric-wieser commented Apr 21, 2017 •

Copy link
Copy Markdown
Member

Looks good to me, although this is made moot by #8970.

Probably should test the ravel case that brought this up

@juliantaylor

Copy link
Copy Markdown
Contributor Author

added a test

Comment thread numpy/core/tests/test_multiarray.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a assert_equal(xx.ravel().dtype, xx.dtype) too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ravel makes a copy here which converts it to 'S1'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a test with a simple indexing view

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure ravel makes a copy? I've found a bunch of places with zeros-sized items that it returns a view, and generally does the right thing.

Either way, the indexing tests the right thing, so no changes needed.

@eric-wieser eric-wieser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good

Comment thread numpy/core/tests/test_multiarray.py Outdated

@eric-wieser eric-wieser Apr 22, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about eval(repr_str, dict(array=np.array))? I don't think you need any of the line-mangling either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed that is nicer, thanks

@charris charris added the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Apr 22, 2017
@charris

charris commented Apr 22, 2017

Copy link
Copy Markdown
Member

@juliantaylor Needs release note.

@juliantaylor

Copy link
Copy Markdown
Contributor Author

this is a bugfix, no release notes needed

If the array being viewed is a zero sized array, e.g. 'S0' from
structured types, do not change the description to itemsize 1 as this
would expose uninitialized data, e.g. in
TestStructured.test_zero_width_string
@eric-wieser

Copy link
Copy Markdown
Member

I'll wait for @charris to confirm this is OK without a release note, but this looks ready to merge to me (and is no longer moot, since #8970 is somewhat rejected)

@charris charris removed the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Apr 23, 2017
@charris
charris merged commit 4408f74 into numpy:master Apr 23, 2017
@charris

charris commented Apr 23, 2017

Copy link
Copy Markdown
Member

My bad, no release note needed. Merged, thanks @juliantaylor @eric-wieser .

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.

3 participants