103103 "ignore:Channel mismatch between .*channels\\ .tsv and the raw data file "
104104 "detected\\ .:RuntimeWarning:mne"
105105 ),
106+ converting_to_edf = r"ignore:Converting data files to [BE]DF format:RuntimeWarning" ,
107+ edf_date = "ignore:.*limits dates to after 1985-01-01:RuntimeWarning" ,
106108)
107109
108110
@@ -3749,8 +3751,8 @@ def test_write_associated_emptyroom(_bids_validate, tmp_path, empty_room_dtype):
37493751 assert meg_json_data ["AssociatedEmptyRoom" ] == expected_rel
37503752
37513753
3752- def test_preload ( _bids_validate , tmp_path ):
3753- """Test writing custom preloaded raw objects ."""
3754+ def test_preload_errors ( tmp_path ):
3755+ """Test allow_preload error handling ."""
37543756 bids_root = tmp_path / "bids"
37553757 bids_path = _bids_path .copy ().update (root = bids_root )
37563758 sfreq , n_points = 1024.0 , int (1e6 )
@@ -3760,21 +3762,37 @@ def test_preload(_bids_validate, tmp_path):
37603762 raw .orig_format = "single"
37613763 raw .info ["line_freq" ] = 60
37623764
3765+ shared_kwargs = dict (raw = raw , bids_path = bids_path , verbose = False , overwrite = True )
37633766 # reject preloaded by default
37643767 with pytest .raises (ValueError , match = "allow_preload" ):
3765- write_raw_bids (raw , bids_path , verbose = False , overwrite = True )
3768+ write_raw_bids (** shared_kwargs )
37663769
37673770 # preloaded raw must specify format
37683771 with pytest .raises (ValueError , match = "format" ):
3769- write_raw_bids (
3770- raw , bids_path , allow_preload = True , verbose = False , overwrite = True
3771- )
3772+ write_raw_bids (** shared_kwargs , allow_preload = True )
37723773
3774+
3775+ @pytest .mark .filterwarnings (
3776+ warning_str ["converting_to_edf" ],
3777+ warning_str ["edfblocks" ],
3778+ )
3779+ @pytest .mark .parametrize ("format,ch_type" , (("BrainVision" , "eeg" ), ("EDF" , "seeg" )))
3780+ def test_preload (_bids_validate , tmp_path , format , ch_type ):
3781+ """Test writing custom preloaded raw objects."""
3782+ bids_root = tmp_path / "bids"
3783+ bids_path = _bids_path .copy ().update (root = bids_root )
3784+ sfreq = 1024.0
3785+ info = mne .create_info (["ch1" , "ch2" ], sfreq , ch_type )
3786+ data = np .zeros ((2 , 100 ), dtype = np .float32 )
3787+ data [0 , 5 ] = 1.0 # avoid physical_min == physical_max
3788+ raw = mne .io .RawArray (data , info )
3789+ raw .orig_format = "single"
3790+ raw .info ["line_freq" ] = 60
37733791 write_raw_bids (
37743792 raw ,
37753793 bids_path ,
37763794 allow_preload = True ,
3777- format = "BrainVision" ,
3795+ format = format ,
37783796 verbose = False ,
37793797 overwrite = True ,
37803798 )
0 commit comments