@testing.requires_testing_data
def test_preload_modify():
 tempdir = _TempDir()
 rng = np.random.RandomState(0)
 for preload in [False, True, 'memmap.dat']:
  raw = read_raw_fif(fif_fname, preload=preload)
  nsamp = ((raw.last_samp - raw.first_samp) + 1)
  picks = pick_types(raw.info, meg='grad', exclude='bads')
  data = rng.randn(len(picks), (nsamp // 2))
  try:
   raw[picks, :(nsamp // 2)] = data
  except RuntimeError as err:
   if (not preload):
    continue
   else:
    raise err
  tmp_fname = op.join(tempdir, 'raw.fif')
  raw.save(tmp_fname, overwrite=True)
  raw_new = read_raw_fif(tmp_fname)
  (data_new, _) = raw_new[picks, :(nsamp / 2)]
  assert_allclose(data, data_new)

@ testing . requires_testing_data def test_preload_modify ( ) : tempdir = _TempDir ( ) rng = np . random . RandomState ( 0 ) for preload in [ False , True , 'memmap.dat' ] : raw = read_raw_fif ( fif_fname , preload = preload ) nsamp = ( ( raw . last_samp - raw . first_samp ) + 1 ) picks = pick_types ( raw . info , meg = 'grad' , exclude = 'bads' ) data = rng . randn ( len ( picks ) , ( nsamp // 2 ) ) try : raw [ picks , : ( nsamp // 2 ) ] = data except RuntimeError as err : if ( not preload ) : continue else : raise err tmp_fname = op . join ( tempdir , 'raw.fif' ) raw . save ( tmp_fname , overwrite = True ) raw_new = read_raw_fif ( tmp_fname ) ( data_new , _ ) = raw_new [ picks , : ( nsamp / 2 ) ] assert_allclose ( data , data_new )
test preloading and modifying data .