33# Copyright the MNE-Python contributors.
44
55import datetime
6+ import gc
67import os
78import pathlib
89import pickle
@@ -315,7 +316,8 @@ def test_multiple_files(tmp_path):
315316 )
316317 _compare_combo (raw , raw_combo , times , n_times )
317318 raw_combo = concatenate_raws (
318- [read_raw_fif (f ) for f in [fif_fname , fif_fname ]], preload = "memmap8.dat"
319+ [read_raw_fif (f ) for f in [fif_fname , fif_fname ]],
320+ preload = tmp_path / "memmap8.dat" ,
319321 )
320322 _compare_combo (raw , raw_combo , times , n_times )
321323 assert raw [:, :][0 ].shape [1 ] * 2 == raw_combo0 [:, :][0 ].shape [1 ]
@@ -349,13 +351,13 @@ def test_multiple_files(tmp_path):
349351
350352 raw_combo = concatenate_raws (
351353 [read_raw_fif (fif_fname , preload = False ), read_raw_fif (fif_fname , preload = True )],
352- preload = "memmap3.dat" ,
354+ preload = tmp_path / "memmap3.dat" ,
353355 )
354356 _compare_combo (raw , raw_combo , times , n_times )
355357
356358 raw_combo = concatenate_raws (
357359 [read_raw_fif (fif_fname , preload = True ), read_raw_fif (fif_fname , preload = True )],
358- preload = "memmap4.dat" ,
360+ preload = tmp_path / "memmap4.dat" ,
359361 )
360362 _compare_combo (raw , raw_combo , times , n_times )
361363
@@ -364,7 +366,7 @@ def test_multiple_files(tmp_path):
364366 read_raw_fif (fif_fname , preload = False ),
365367 read_raw_fif (fif_fname , preload = False ),
366368 ],
367- preload = "memmap5.dat" ,
369+ preload = tmp_path / "memmap5.dat" ,
368370 )
369371 _compare_combo (raw , raw_combo , times , n_times )
370372
@@ -957,9 +959,9 @@ def test_io_complex(tmp_path, dtype):
957959
958960
959961@testing .requires_testing_data
960- def test_getitem ():
962+ def test_getitem (tmp_path ):
961963 """Test getitem/indexing of Raw."""
962- for preload in [False , True , "memmap1.dat" ]:
964+ for preload in [False , True , tmp_path / "memmap1.dat" ]:
963965 raw = read_raw_fif (fif_fname , preload = preload )
964966 data , times = raw [0 , :]
965967 data1 , times1 = raw [0 ]
@@ -1078,9 +1080,11 @@ def test_proj(tmp_path):
10781080
10791081
10801082@testing .requires_testing_data
1081- @pytest .mark .parametrize ("preload" , [False , True , "memmap2.dat " ])
1083+ @pytest .mark .parametrize ("preload" , [False , True , "memmap " ])
10821084def test_preload_modify (preload , tmp_path ):
10831085 """Test preloading and modifying data."""
1086+ if preload == "memmap" :
1087+ preload = tmp_path / "memmap2.dat"
10841088 rng = np .random .default_rng (0 )
10851089 raw = read_raw_fif (fif_fname , preload = preload )
10861090
@@ -2030,6 +2034,9 @@ def test_memmap(tmp_path):
20302034 raw_0 ._data [:] = 0.0
20312035 assert not raw_0 ._data .any ()
20322036 assert raw_1 ._data [:1 , 3 :5 ].all ()
2037+ del raw_0 , raw_1
2038+ gc .collect ()
2039+ assert Path (memmaps [3 ]).is_file ()
20332040 # other things like drop_channels and crop work but do not use memmapping,
20342041 # eventually we might want to add support for some of these as users
20352042 # require them.
0 commit comments