[Numpy-discussion] Comparing the precision of dtypes?

Hans Meine meine@informatik.uni-hamburg...
Thu Jul 23 04:20:12 CDT 2009

```On Wednesday 22 July 2009 17:16:31 Ralf Gommers wrote:
> Examples where min/max probably does not do what you want, and
> find_common_type does:
>
> In [49]: max(float, float32)
> Out[49]: <type 'numpy.float32'>
> In [50]: find_common_type([], [float, float32])
> Out[50]: dtype('float64')

I don't understand the following behaviour:

In [5]: numpy.find_common_type([float32,int32],[])
Out[5]: dtype('float32')

In [6]: numpy.find_common_type([int32,float32],[])
Out[6]: dtype('int32')

In both cases, I would actually expect float64 to be the answer (since int32
does not "fit into" float32).  And I wonder why it depends on the order?

When I actually try the same with arrays, I get float64 as expected:

In [8]: a = numpy.array([1,2,3], int32)

In [9]: b = numpy.array([1,2,3], float32)

In [10]: a + b
Out[10]: array([ 2.,  4.,  6.])

In [11]: b + a
Out[11]: array([ 2.,  4.,  6.])

Is this a known bug in numpy 1.3.0, or am I missing something?

Have a nice day!
Hans
```