Author: Maciej Fijalkowski <[email protected]>
Branch: numpy-refactor
Changeset: r57282:3cdcacaba1ff
Date: 2012-09-11 14:51 +0200
http://bitbucket.org/pypy/pypy/changeset/3cdcacaba1ff/

Log:    fixes for swapaxes

diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py 
b/pypy/module/micronumpy/arrayimpl/scalar.py
--- a/pypy/module/micronumpy/arrayimpl/scalar.py
+++ b/pypy/module/micronumpy/arrayimpl/scalar.py
@@ -18,7 +18,7 @@
         raise Exception("Don't call setitem on scalar iterators")
 
     def done(self):
-        raise Exception("should not call done on scalars")
+        raise Exception("should not call done on scalar")
 
     def reset(self):
         pass
@@ -80,7 +80,7 @@
         raise Exception("axis iter should not happen on scalar")
 
     def swapaxes(self, axis1, axis2):
-        return self
+        raise Exception("should not be called")
 
     def fill(self, w_value):
         self.value = w_value
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -193,6 +193,8 @@
         --------
         numpy.swapaxes : equivalent function
         """
+        if self.is_scalar():
+            return self
         return self.implementation.swapaxes(axis1, axis2)
 
     def descr_tolist(self, space):
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1552,6 +1552,7 @@
         # test virtual
         assert ((x + x).swapaxes(0,1) == array([[[ 2,  4,  6], [14, 16, 18]], 
                                          [[ 8, 10, 12], [20, 22, 24]]])).all()
+        assert array(1).swapaxes(10, 12) == 1
 
     def test_filter_bug(self):
         from numpypy import array
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to