[Numpy-discussion] find_common_type broken?

Ralf Gommers ralf.gommers at googlemail.com
Sun Jul 12 01:16:58 EDT 2009


Hi,

While documenting find_common_type I found two problems. As I understand it,
"common type" is a type to which all input types can be cast without loss of
precision.

1. using any array types always returns "dtype('object')":
>>> np.find_common_type([np.ndarray], [])
dtype('object')
>>> np.find_common_type([np.ndarray, np.ma.MaskedArray, np.recarray], [])
dtype('object')

2. the second example below seems to be wrong, it should return
dtype('float64'):
>>> np.find_common_type([], [np.int64, np.float64])
dtype('float64')
>>> np.find_common_type([], [np.int64, np.float32])
dtype('int64')


One other question, why do type comparisons for numpy types and python
built-ins do the opposite:
>>> np.int32 > np.float32
False
>>> np.int64 > np.float64
False
>>> int > float
True

The numpy result makes more sense to me, what's going on with the builtins?

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090712/5e21109a/attachment.html>


More information about the NumPy-Discussion mailing list