[Numpy-discussion] cannot decode 'S'

Chris Barker chris.barker at noaa.gov
Thu Jan 23 14:40:43 EST 2014


Josef,

Nice find -- another reason why 'S' can NOT be used a-is for arbitrary
bytes.

See the other thread for my proposals about that.


> messy workaround (arrays in contrast to scalars are not truncated in
> `tostring`)
>
> >>> [a[i:i+1].tostring().decode('utf-16LE') for i in range(len(a))]
> ['Õsc', 'zxc']
>
>
I think the real "work around" is to not try to store arbitrary bytes --
i.e. encoded text, in the 'S' dtype.

But  is there a convenient way to do it with other existing numpy types?

I tried to do it with uint8, and it's really awkward....

-CHB





-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140123/a5364405/attachment.html>


More information about the NumPy-Discussion mailing list