[Numpy-discussion] Comparing the precision of dtypes?

Ralf Gommers ralf.gommers@googlemail....
Wed Jul 22 10:51:09 CDT 2009


2009/7/22 Hans Meine <meine@informatik.uni-hamburg.de>

> On Wednesday 22 July 2009 17:16:31 Ralf Gommers wrote:
> > 2009/7/22 Hans Meine <meine@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...


Hmm, not for me:
In [56]: min(int16, int32)
Out[56]: <type 'numpy.int16'>
In [57]: max(int16, int32)
Out[57]: <type 'numpy.int32'>

On the other hand, even though dtype=int gives you an int32 array this does
not work as expected:
In [59]: min(int16, int)
Out[59]: <type 'int'>

Well I guess that shows how fragile using min/max is. And I don't think
there's a way to make it always work because there are types that are not
simply bigger/smaller but of a different kind.

Cheers,
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090722/06fb59f1/attachment.html 


More information about the NumPy-Discussion mailing list