Commit 88821f1a authored by Stefan Behnel's avatar Stefan Behnel

Try to work around differing GC behaviour of NumPy 1.14 in a doctest.

parent 56f03d35
...@@ -44,6 +44,14 @@ def testcase_numpy_1_5(f): ...@@ -44,6 +44,14 @@ def testcase_numpy_1_5(f):
__test__[f.__name__] = f.__doc__ __test__[f.__name__] = f.__doc__
return f return f
def gc_collect_if_required():
major, minor, *rest = np.__version__.split('.')
if (int(major), int(minor)) >= (1, 14):
import gc
gc.collect()
# #
### Test slicing memoryview slices ### Test slicing memoryview slices
# #
...@@ -406,13 +414,13 @@ def test_coerce_to_numpy(): ...@@ -406,13 +414,13 @@ def test_coerce_to_numpy():
@testcase_numpy_1_5 @testcase_numpy_1_5
def test_memslice_getbuffer(): def test_memslice_getbuffer():
""" """
>>> test_memslice_getbuffer() >>> print(test_memslice_getbuffer()); gc_collect_if_required()
[[ 0 2 4] [[ 0 2 4]
[10 12 14]] [10 12 14]]
callback called callback called
""" """
cdef int[:, :] array = create_array((4, 5), mode="c", use_callback=True) cdef int[:, :] array = create_array((4, 5), mode="c", use_callback=True)
print np.asarray(array)[::2, ::2] return np.asarray(array)[::2, ::2]
cdef class DeallocateMe(object): cdef class DeallocateMe(object):
def __dealloc__(self): def __dealloc__(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment