[Numpy-discussion] Comparing the precision of dtypes?

Hans Meine meine at informatik.uni-hamburg.de
Wed Jul 22 11:37:23 EDT 2009


On Wednesday 22 July 2009 17:16:31 Ralf Gommers wrote:
> 2009/7/22 Hans Meine <meine at informatik.uni-hamburg.de>
> >  type = min(float32, a.dtype.type, b.dtype.type)
>
> Are you looking for the type to cast to? In that case I guess you meant
> max() not min().

No, at least for integers min(..) does what one would expect max(..) to do.
But...

> > How hackish is this?  Is this likely to break on other platforms/numpy
> > versions?  Is there a better API for type promotion?
>
> That could give unexpected results. Useful functions are find_common_type,

..find_common_type() is exactly what we were looking for;
thanks a lot for the pointer!

Have a nice day,
  Hans



More information about the NumPy-Discussion mailing list