Commits

mattip committed 862f40e

cleanup, make the prod test pass for numpypy and numpy ( -A )

  • Participants
  • Parent commits 84c4bc0

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_dtype.py

-import sys
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec

pypy/module/micronumpy/test/test_numarray.py

         assert (array([[1,2],[3,4]]).prod(1) == [2, 12]).all()
 
     def test_prod(self):
-        from numpypy import array, int_, dtype
+        from numpypy import array, dtype
         a = array(range(1, 6))
         assert a.prod() == 120.0
         assert a[:4].prod() == 24.0
         for dt in ['bool', 'int8', 'uint8', 'int16', 'uint16']:
             a = array([True, False], dtype=dt)
             assert a.prod() == 0
-            assert a.prod().dtype is dtype('uint' if dt[0] == 'u' else 'int')
  1. Brian Kearns

    This test was broken for a reason. If you check the dtype.char or dtype.num it is not maintained as expected, thus is fails, but they still compare equal. We want to make sure char/num are preserved as in numpy, so the is comparison was useful. Please take more care when blindly 'fixing' test failures by just modifying the test.

    1. mattip author

      So the test should either have had a comment what the problem is, or fail in such a way to indicate the problem In any case, the test was failing for numpy as well.

+            assert a.prod().dtype == dtype('uint' if dt[0] == 'u' else 'int')
         for dt in ['l', 'L', 'q', 'Q', 'e', 'f', 'd', 'F', 'D']:
             a = array([True, False], dtype=dt)
             assert a.prod() == 0
-            assert a.prod().dtype is dtype(dt)
+            assert a.prod().dtype == dtype(dt)
  1. Brian Kearns

    Specifically, here, a.prod() where a.dtype.char == q should return result with dtype.char == q. Putting == allows a return result with dtype.char == l to pass, which is wrong.

 
     def test_max(self):
         from numpypy import array, zeros