Author: Brian Kearns <[email protected]>
Branch:
Changeset: r73668:8faa11984f7a
Date: 2014-09-23 15:15 -0400
http://bitbucket.org/pypy/pypy/changeset/8faa11984f7a/
Log: fix ndarray.swapaxes no-op cases (issue 1872)
diff --git a/pypy/module/micronumpy/ndarray.py
b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -407,7 +407,7 @@
--------
numpy.swapaxes : equivalent function
"""
- if self.is_scalar():
+ if axis1 == axis2 or len(self.get_shape()) <= 1:
return self
return self.implementation.swapaxes(space, self, axis1, axis2)
diff --git a/pypy/module/micronumpy/test/test_ndarray.py
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -2020,6 +2020,10 @@
def test_swapaxes(self):
from numpypy import array
+ x = array([])
+ assert x.swapaxes(0, 2) is x
+ x = array([[1, 2]])
+ assert x.swapaxes(0, 0) is x
# testcases from numpy docstring
x = array([[1, 2, 3]])
assert (x.swapaxes(0, 1) == array([[1], [2], [3]])).all()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit