[Numpy-discussion] Bug in numarray.typecode()?

Todd Miller jmiller at stsci.edu
Tue Jul 6 06:35:11 EDT 2004


On Sat, 2004-07-03 at 13:10, Philip Austin wrote:
> I'm in the process of switching to numarray, but I still
> need typecode().  I notice that, although it's discouraged,
> the typecode ids have been extended to all new numarray
> types described in table 4.1 (p. 19) of the manual, except UInt64.
> That is, the following script:
> 
> import numarray as Na
> print "Numarray version: ",Na.__version__
> print Na.array([1],'Int8').typecode()
> print Na.array([1],'UInt8').typecode()
> print Na.array([1],'Int16').typecode()
> print Na.array([1],'UInt16').typecode()
> print Na.array([1],'Int32').typecode()
> print Na.array([1],'UInt32').typecode()
> print Na.array([1],'Float32').typecode()
> print Na.array([1],'Float64').typecode()
> print Na.array([1],'Complex32').typecode()
> print Na.array([1],'Complex64').typecode()
> print Na.array([1],'Bool').typecode()
> print Na.array([1],'UInt64').typecode()
> 
> prints:
> 
> Numarray version:  1.0
> 1
> b
> s
> w
> l
> u
> f
> d
> F
> D
> 1
> Traceback (most recent call last):
>   File "<stdin>", line 14, in ?
>   File "/usr/lib/python2.3/site-packages/numarray/numarraycore.py", line 1092, in typecode
>     return _nt.typecode[self._type]
> KeyError: UInt64
> 
> Should this print 'U'?

I think it could,  but I wouldn't go so far as to say it should. 
typecode() is there for backward compatibility with Numeric.  Since 'U'
doesn't work for Numeric,  I see no point in adding it to numarray. I'm
not sure it would hurt anything other than create the illusion that
something which works on numarray will also work on Numeric.

If anyone has a good reason to add it,  please speak up.

Regards,
Todd





More information about the NumPy-Discussion mailing list