102102 "ignore:Channel mismatch between .*channels\\ .tsv and the raw data file "
103103 "detected\\ .:RuntimeWarning:mne"
104104 ),
105+ converting_to_edf = r"ignore:Converting data files to [BE]DF format:RuntimeWarning" ,
106+ edf_date = "ignore:.*limits dates to after 1985-01-01:RuntimeWarning" ,
105107)
106108
107109
@@ -3744,8 +3746,8 @@ def test_write_associated_emptyroom(_bids_validate, tmp_path, empty_room_dtype):
37443746 assert meg_json_data ["AssociatedEmptyRoom" ] == expected_rel
37453747
37463748
3747- def test_preload ( _bids_validate , tmp_path ):
3748- """Test writing custom preloaded raw objects ."""
3749+ def test_preload_errors ( tmp_path ):
3750+ """Test allow_preload error handling ."""
37493751 bids_root = tmp_path / "bids"
37503752 bids_path = _bids_path .copy ().update (root = bids_root )
37513753 sfreq , n_points = 1024.0 , int (1e6 )
@@ -3755,21 +3757,35 @@ def test_preload(_bids_validate, tmp_path):
37553757 raw .orig_format = "single"
37563758 raw .info ["line_freq" ] = 60
37573759
3760+ shared_kwargs = dict (raw = raw , bids_path = bids_path , verbose = False , overwrite = True )
37583761 # reject preloaded by default
37593762 with pytest .raises (ValueError , match = "allow_preload" ):
3760- write_raw_bids (raw , bids_path , verbose = False , overwrite = True )
3763+ write_raw_bids (** shared_kwargs )
37613764
37623765 # preloaded raw must specify format
37633766 with pytest .raises (ValueError , match = "format" ):
3764- write_raw_bids (
3765- raw , bids_path , allow_preload = True , verbose = False , overwrite = True
3766- )
3767+ write_raw_bids (** shared_kwargs , allow_preload = True )
37673768
3769+
3770+ @pytest .mark .filterwarnings (
3771+ warning_str ["converting_to_edf" ],
3772+ warning_str ["edfblocks" ],
3773+ )
3774+ @pytest .mark .parametrize ("format,ch_type" , (("BrainVision" , "eeg" ), ("EDF" , "seeg" )))
3775+ def test_preload (_bids_validate , tmp_path , format , ch_type ):
3776+ """Test writing custom preloaded raw objects."""
3777+ bids_root = tmp_path / "bids"
3778+ bids_path = _bids_path .copy ().update (root = bids_root )
3779+ sfreq = 1024.0
3780+ info = mne .create_info (["ch1" , "ch2" ], sfreq , ch_type )
3781+ raw = mne .io .RawArray (np .zeros ((2 , 100 ), dtype = np .float32 ), info )
3782+ raw .orig_format = "single"
3783+ raw .info ["line_freq" ] = 60
37683784 write_raw_bids (
37693785 raw ,
37703786 bids_path ,
37713787 allow_preload = True ,
3772- format = "BrainVision" ,
3788+ format = format ,
37733789 verbose = False ,
37743790 overwrite = True ,
37753791 )
0 commit comments