3838# Each test involves loading an image of shape SHAPE, and then slicing it
3939# NITERS times
4040NITERS = 50
41- SHAPE = (100 , 100 , 100 , 100 )
41+ SHAPE = (100 , 100 , 100 , 100 )
4242
4343# One test is run for each combination of SLICEOBJS, KEEP_OPENS, and HAVE_IGZIP
4444
6161
6262@contextlib .contextmanager
6363def patch_indexed_gzip (have_igzip ):
64- with mock .patch ('nibabel.openers.HAVE_INDEXED_GZIP' , have_igzip ), \
65- mock .patch ('nibabel.arrayproxy.HAVE_INDEXED_GZIP' , have_igzip ):
64+
65+ atts = ['nibabel.openers.HAVE_INDEXED_GZIP' ,
66+ 'nibabel.arrayproxy.HAVE_INDEXED_GZIP' ]
67+
68+ with mock .patch (atts [0 ], have_igzip ), mock .patch (atts [1 ], have_igzip ):
6669 yield
6770
6871
@@ -78,12 +81,12 @@ def bench_arrayproxy_slicing():
7881 # because if keep_file_open is False, HAVE_INDEXED_GZIP has no effect
7982 tests = [t for t in tests if not (t [0 ] and not t [1 ])]
8083
81- testfile = 'testfile.nii'
84+ testfile = 'testfile.nii'
8285 testfilegz = 'test.nii.gz'
8386
8487 def get_test_label (test ):
8588 have_igzip = test [0 ]
86- keep_open = test [1 ]
89+ keep_open = test [1 ]
8790
8891 if not (have_igzip and keep_open ):
8992 return 'gzip'
@@ -166,9 +169,9 @@ def testfunc():
166169 gc .collect ()
167170
168171 if memory_usage is not None :
169- membaseline = max (memory_usage (lambda : None ))
170- testmem = max (memory_usage (testfunc )) - membaseline
171- basemem = max (memory_usage (basefunc )) - membaseline
172+ membaseline = max (memory_usage (lambda : None ))
173+ testmem = max (memory_usage (testfunc )) - membaseline
174+ basemem = max (memory_usage (basefunc )) - membaseline
172175 else :
173176 testmem = np .nan
174177 basemem = np .nan
0 commit comments