Commits

Antonio Cuni committed 0805e1a

fix issue1000: None is an acceptable value for numpypy floats and has to be converted to NaN

  • Participants
  • Parent commits 74a2914

Comments (0)

Files changed (2)

File pypy/module/micronumpy/test/test_dtypes.py

         assert numpy.float64('23.4') == numpy.float64(23.4)
         raises(ValueError, numpy.float64, '23.2df')
 
+    def test_float_None(self):
+        import _numpypy as numpy
+        from math import isnan
+        assert isnan(numpy.float32(None))
+        assert isnan(numpy.float64(None))
+        assert isnan(numpy.float128(None))
+
     def test_longfloat(self):
         import _numpypy as numpy
         # it can be float96 or float128

File pypy/module/micronumpy/types.py

     _mixin_ = True
 
     def _coerce(self, space, w_item):
+        if space.is_none(w_item):
+            return self.box(rfloat.NAN)
         return self.box(space.float_w(space.call_function(space.w_float, w_item)))
 
     def str_format(self, box):