[Numpy-tickets] [NumPy] #290: Some inconsistency in 'i' typecode
NumPy
numpy-tickets at scipy.net
Sat Sep 23 13:51:52 CDT 2006
#290: Some inconsistency in 'i' typecode
--------------------+-------------------------------------------------------
Reporter: faltet | Owner: somebody
Type: defect | Status: closed
Priority: normal | Milestone:
Component: Other | Version:
Severity: normal | Resolution: invalid
Keywords: |
--------------------+-------------------------------------------------------
Changes (by oliphant):
* status: new => closed
* resolution: => invalid
Comment:
You are confusing equality testing on 2 different things: data-type object
versus type objects that the data-types "wrap".
Type-objects compare as equal only if they are the same type. numpy.intc
(the type object returned from dtype('i').type) and numpy.int_ (the type
object returned from dtype('l').type) are two different type objects ---
note that they both print the same however as numpy.int32 (on 32-bit
platforms). It can be a bit confusing, but it is intentional to shield
the user from having to worry about it (I don't know why you keep worrying
about it :-)). While the type objects are technically different, they
represent the same "data-type". Therefore, it doesn't matter which one
you use.
The data-type equality testing tests for "equivalency" of types (not
equality of type objects). Therefore, dtype(numpy.intc) ==
dtype(numpy.int_). Also, data-type equality testing "converts" the object
to a data-type object for convenience.
So, my advice is to not use type-object equality testing. Instead use
dtype testing if you are trying to guarantee data-type compatibility.
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/290>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list