[Numpy-discussion] nan_to_num and bool arrays

Nicolas Rougier Nicolas.Rougier at loria.fr
Fri Dec 11 03:50:10 EST 2009


Hello,

Using both numpy 1.3.0 and 1.4.0rc1 I got the following exception using
nan_to_num on a bool array, is that the expected behavior ?


>>> import numpy
>>> Z = numpy.zeros((3,3),dtype=bool)
>>> numpy.nan_to_num(Z)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/numpy/lib/type_check.py", line
374, in nan_to_num
    maxf, minf = _getmaxmin(y.dtype.type)
  File "/usr/lib/python2.6/dist-packages/numpy/lib/type_check.py", line
307, in _getmaxmin
    f = getlimits.finfo(t)
  File "/usr/lib/python2.6/dist-packages/numpy/core/getlimits.py", line
103, in __new__
    raise ValueError, "data type %r not inexact" % (dtype)
ValueError: data type <type 'numpy.bool_'> not inexact



Nicolas




More information about the NumPy-Discussion mailing list