From fae8369fba4a683783280b044915b11bbca07a44 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Sun, 26 May 2013 17:03:51 +0200 Subject: 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 --- numpy/lib/tests/test_shape_base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'numpy/lib/tests/test_shape_base.py') 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)): -- cgit v1.2.1