From 684f27f9849fa0db852033917911328bf253a6ac Mon Sep 17 00:00:00 2001 From: Michael Lamparski Date: Tue, 29 Aug 2017 18:26:26 -0400 Subject: TST: test for leak in np.dot of size 0 arrays --- numpy/core/tests/test_multiarray.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index ba4b0e0d8..74f6a3af9 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -2497,6 +2497,17 @@ class TestMethods(object): if HAS_REFCOUNT: assert_(sys.getrefcount(a) < 50) + def test_size_zero_memleak(self): + # Regression test for issue 9615 + # Exercises a special-case code path for dot products of length + # zero in cblasfuncs (making it is specific to floating dtypes). + a = np.array([], dtype=np.float64) + x = np.array(2.0) + for _ in range(100): + np.dot(a, a, out=x) + if HAS_REFCOUNT: + assert_(sys.getrefcount(x) < 50) + def test_trace(self): a = np.arange(12).reshape((3, 4)) assert_equal(a.trace(), 15) -- cgit v1.2.1