[Numpy-discussion] small suggestion for numpy.testing utils

Darren Dale dsdale24@gmail....
Sun Feb 22 14:17:36 CST 2009


Hello,

I am using numpy's assert_array_equal and assert_array_almost_equal to unit
test my physical quantities package. I made a single minor change to
assert_array_compare that I think might make these functions more useful to
ndarray subclasses, and thought maybe they could be useful to numpy itself.
I tried applying this diff to numpy and running the test suite, and instead
of 9 known failures I got 1 known failure, 11 skips, 2 errors and 2
failures. Perhaps it is possible that by not forcing the input arrays to be
ndarray instances, some additional numpy features are exposed.

Thanks,
Darren

$ svn diff
Index: numpy/testing/utils.py
===================================================================
--- numpy/testing/utils.py      (revision 6370)
+++ numpy/testing/utils.py      (working copy)
@@ -240,9 +240,9 @@

 def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
                          header=''):
-    from numpy.core import asarray, isnan, any
-    x = asarray(x)
-    y = asarray(y)
+    from numpy.core import array, isnan, any
+    x = array(x, copy=False, subok=True)
+    y = array(y, copy=False, subok=True)

     def isnumber(x):
         return x.dtype.char in '?bhilqpBHILQPfdgFDG'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20090222/641d41fc/attachment.html 


More information about the Numpy-discussion mailing list