[Numpy-discussion] Status of NumPy and Python 3.3
Ondřej Čertík
ondrej.certik at gmail.com
Sat Jul 28 11:04:57 EDT 2012
On Sat, Jul 28, 2012 at 7:58 AM, Ondřej Čertík <ondrej.certik at gmail.com> wrote:
[...]
> Here is the code in defchararray.py:
>
>
> 1911 if not _globalvar and self.dtype.char not in 'SUbc':
> 1912 raise ValueError("Can only create a chararray from
> string data.")
> 1913
> 1914 def __getitem__(self, obj):
> 1915 val = ndarray.__getitem__(self, obj)
> 1916 -> if issubclass(val.dtype.type, character) and not _len(val) == 0:
> 1917 temp = val.rstrip()
> 1918 if _len(temp) == 0:
> 1919 val = ''
> 1920 else:
> 1921 val = temp
>
>
> and here is some debugging info:
>
Python 3.3:
>
> (Pdb) p self
> (Pdb) p obj
> (0, 0)
> (Pdb) p val
> 'abc'
> (Pdb) p type(val)
> <class 'str'>
Python 3.2:
(Pdb) p self
chararray([['abc', '123'],
['789', 'xyz']],
dtype='<U3')
(Pdb) p obj
(0, 0)
(Pdb) p val
'abc'
(Pdb) p type(val)
<class 'numpy.str_'>
So I think there might be some conversion issues int the chararray,
that instead of using numpy.str_, it uses Python's str.
Weird.
Ondrej
More information about the NumPy-Discussion
mailing list