[Numpy-discussion] Two bugs in numerictypes.py

Edward C. Jones edcjones at erols.com
Wed Dec 18 14:27:03 CST 2002


In "numerictypes.py' it says "This module is designed so 'from 
numerictypes import *' is safe." When I "import numerictypes", and run 
dir(), I get:

['Any', 'AnyType', 'Bool', 'BooleanType', 'Byte', 'Complex', 
'Complex32', 'Complex64', 'ComplexType', 'Double', 'Float', 'Float32', 
'Float64', 'FloatingType', 'Int', 'Int16', 'Int32', 'Int64', 'Int8', 
'IntegralType', 'Long', 'MAX_ALIGN', 'NumericType', 'Short', 
'SignedIntegralType', 'SignedType', 'UInt16', 'UInt32', 'UInt64', 
'UInt8', 'UnsignedIntegralType', 'UnsignedType', '__builtins__', 
'__doc__', '__name__', 'genericCoercions', 'genericPromotionExclusions', 
'genericTypeRank', 'inttype1', 'inttype2', 'kind', 'mapto', 'maptype1', 
'maptype2', 'nt1', 'nt2', 'ntypesize1', 'ntypesize2', 'numinclude', 
'outtype', 'pythonTypeMap', 'pythonTypeRank', 'rank1', 'rank2', 
'scalarTypeMap', 'signedtype1', 'signedtype2', 'typeDict', 'typecode', 
'typecodes']

A bunch of leading "_" are needed.

----------------

My code is:

#! /usr/bin/env python
from numerictypes import UInt8
print UInt8 == "ABC"

The message is:

Traceback (most recent call last):
   File "./silly02.py", line 5, in ?
     print UInt8 == "ABC"
   File "/usr/lib/python2.2/site-packages/numarray/numerictypes.py",
line 101, in __cmp__
     other = typeDict[other]
KeyError: ABC

I would expect that the only object == to UInt8 be itself. Maybe add a 
function comparetypecodes(x, y) which returns True iff x and y are 
either NumericType's or strings which represent the same type.





More information about the Numpy-discussion mailing list