[Numpy-discussion] RE: [Numpy-user] possible error with isarrtype

Colin J. Williams cjw at sympatico.ca
Wed Feb 1 08:17:09 CST 2006


Travis Oliphant wrote:
> Colin J. Williams wrote:
>
>> One of the deprecated names is ArrayType.  This seems to be closer to 
>> the Python style than ndarray.
>
>
> Not really.
I agree with what you say below, but doesn't ArrayType have a greater
similarity to the Python types than ndarray?

[Dbg]>>> import types
[Dbg]>>> dir(types)
['BooleanType', 'BufferType', 'BuiltinFunctionType',
'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType',
'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType',
'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType',
'Instance
Type', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MethodType',
'ModuleType', 'NoneType', 'NotImplementedType', 'ObjectType',
'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType',
'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRan
geType', '__builtins__', '__doc__', '__file__', '__name__']
[Dbg]>>>

I presume that the aim is still that numpy will become a part of the
Python offering.

Colin W.
> Rather than test:
> type(var) == types.IntType
> you should be testing
> isinstance(var, int)
>
> just like rather than testing
> type(somearray) == ArrayType
>
> you should be testing
> isinstance(somearray, ndarray)
>
> Python style has changed a bit since 2.2 allowed sub-typing builtings
>
> -Travis
>






More information about the Numpy-discussion mailing list