summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2013-05-26 17:03:51 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2013-05-28 20:27:34 +0200
commitfae8369fba4a683783280b044915b11bbca07a44 (patch)
tree0551c9f7fecb1f6ecaab6937a3c9d79f5ffcc20b /numpy/lib/tests
parent91ba6d616b528a60e6bdcc4c922b29f8173406aa (diff)
downloadnumpy-fae8369fba4a683783280b044915b11bbca07a44.tar.gz
ENH: implement may_share_memory in C
memmap needs to call it in __array_finalize__ to determine if it can drop the references on copies. The python version if may_share_memory caused significant slowdowns when slicing these maps. closes gh-3364
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_shape_base.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py
index 3c270088f..a92ddde83 100644
--- a/numpy/lib/tests/test_shape_base.py
+++ b/numpy/lib/tests/test_shape_base.py
@@ -315,6 +315,21 @@ class TestTile(TestCase):
assert_equal(large, klarge)
+class TestMayShareMemory(TestCase):
+ def test_basic(self):
+ d = ones((50, 60))
+ d2 = ones((30, 60, 6))
+ self.assertTrue(may_share_memory(d, d))
+ self.assertTrue(may_share_memory(d, d[::-1]))
+ self.assertTrue(may_share_memory(d, d[::2]))
+ self.assertTrue(may_share_memory(d, d[1:, ::-1]))
+
+ self.assertFalse(may_share_memory(d[::-1], d2))
+ self.assertFalse(may_share_memory(d[::2], d2))
+ self.assertFalse(may_share_memory(d[1:, ::-1], d2))
+ self.assertTrue(may_share_memory(d2[1:, ::-1], d2))
+
+
# Utility
def compare_results(res,desired):
for i in range(len(desired)):