Fix for issue #385. #388

Closed
wants to merge 3 commits into
from

5 participants

@jwoillez

No description provided.

@travisbot

This pull request passes (merged 2f28574 into 63cd8f3).

@certik

@jwoillez, thanks for the patch. Can you please add a test for this issue as well? That fails before your patch and works after your patch is applied.

@jwoillez

@certik, hopefully, this is the right location for such a test.
Should tests for np.str_ and np.unicode_ also be added?

@travisbot

This pull request fails (merged be46fc7 into 63cd8f3).

@jwoillez

Passes on python 2, fails on python 3. Unfortunately, I don't have access to numpy on python 3 yet.

@certik

Just install python 3.2 from python.org, numpy can then be installed using "python3 setup.py install", and it will just work.

@travisbot

This pull request fails (merged 30a899b into 63cd8f3).

@jwoillez

And now it fails for python2.5 (2.6 and 2.7 are OK) because bytes objects don't exist there. And for python3 because the formatting gives different results.

I will have to give all this some more thoughts. Maybe my fix is not the best fix.

@charris
NumPy member

Going to ping the travis bot. support for 2.5 & 2.4 dropped, so that should help.

@charris charris closed this Apr 2, 2013
@charris charris reopened this Apr 2, 2013
@charris
NumPy member

The problem is that void arrays print differently in python3, as a list of byte values rather than an ascii string. This needs a decision and fix for the str function of void arrays. I think the list might be prettier, but perhaps folks expect void to be treated as an ascii string, which is what python2 does.

@njsmith
NumPy member
@charris
NumPy member

I'm tending towards byte strings, especially for repr since passing lists for array creation with dtype=void doesn't work correctly.

@charris charris was assigned Apr 3, 2013
@jwoillez

Related to this printing issue, I also noticed that, with python3 & latest numpy, we get the following:

Python 3.3.0 (default, Nov 23 2012, 10:26:01) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.8.0.dev-30a899b'
>>> numpy.void(b"abc")
 [97 98 99]
>>> numpy.void(b"abc").dtype
dtype('V3')
>>> numpy.array2string(numpy.void(b"abc"))
'array([97, 98, 99], dtype=int8)'

numpy.array2string does not seem to interpret this numpy.void properly.

What should the expected behavior be?

@charris
NumPy member

I think it should be a byte string.

@charris
NumPy member

This appears fixed by #4401, so closing. The test failure would remain. Thinking about it, I'm no longer convinced that printing a byte string is preferable to the python3 version...

@charris charris closed this Mar 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment