[Numpy-discussion] Comparing the precision of dtypes?
Wed Jul 22 10:51:09 CDT 2009
2009/7/22 Hans Meine <email@example.com>
> On Wednesday 22 July 2009 17:16:31 Ralf Gommers wrote:
> > 2009/7/22 Hans Meine <firstname.lastname@example.org>
> > > 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.
Hmm, not for me:
In : min(int16, int32)
Out: <type 'numpy.int16'>
In : max(int16, int32)
Out: <type 'numpy.int32'>
On the other hand, even though dtype=int gives you an int32 array this does
not work as expected:
In : min(int16, int)
Out: <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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion