[Numpy-discussion] cannot decode 'S'

2014-01-23 Thread josef . pktd
truncating null bytes in 'S' breaks decoding that needs them a = np.array([si.encode('utf-16LE') for si in ['Õsc', 'zxc']], dtype='S') a array([b'\xd5\x00s\x00c', b'z\x00x\x00c'], dtype='|S6') [ai.decode('utf-16LE') for ai in a] Traceback (most recent call last): File pyshell#118,

Re: [Numpy-discussion] cannot decode 'S'

2014-01-23 Thread Chris Barker
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',