33# Authors: The MNE-BIDS developers
44# SPDX-License-Identifier: BSD-3-Clause
55
6+
67import json
78import os
89import os .path as op
@@ -857,9 +858,7 @@ def test_handle_chpi_reading(tmp_path):
857858 meg_json_data_freq_mismatch ["HeadCoilFrequency" ][0 ] = 123
858859 _write_json (meg_json_path , meg_json_data_freq_mismatch , overwrite = True )
859860
860- with (
861- pytest .warns (RuntimeWarning , match = "Defaulting to .* mne.Raw object" ),
862- ):
861+ with (pytest .warns (RuntimeWarning , match = "Defaulting to .* mne.Raw object" ),):
863862 raw_read = read_raw_bids (bids_path , extra_params = dict (allow_maxshield = "yes" ))
864863
865864 # cHPI "off" according to sidecar, but present in the data
@@ -1080,9 +1079,7 @@ def test_handle_ieeg_coords_reading(bids_path, tmp_path):
10801079 _to_tsv (electrodes_dict , electrodes_fname )
10811080 # popping off channels should not result in an error
10821081 # however, a warning will be raised through mne-python
1083- with (
1084- pytest .warns (RuntimeWarning , match = "DigMontage is only a subset of info" ),
1085- ):
1082+ with (pytest .warns (RuntimeWarning , match = "DigMontage is only a subset of info" ),):
10861083 read_raw_bids (bids_path = bids_fname , verbose = False )
10871084
10881085 # make sure montage is set if there are coordinates w/ 'n/a'
@@ -1098,9 +1095,7 @@ def test_handle_ieeg_coords_reading(bids_path, tmp_path):
10981095 # electrode coordinates should be nan
10991096 # when coordinate is 'n/a'
11001097 nan_chs = [electrodes_dict ["name" ][i ] for i in [0 , 3 ]]
1101- with (
1102- pytest .warns (RuntimeWarning , match = "There are channels without locations" ),
1103- ):
1098+ with (pytest .warns (RuntimeWarning , match = "There are channels without locations" ),):
11041099 raw = read_raw_bids (bids_path = bids_fname , verbose = False )
11051100 for idx , ch in enumerate (raw .info ["chs" ]):
11061101 if ch ["ch_name" ] in nan_chs :
@@ -1228,9 +1223,7 @@ def test_handle_non_mne_channel_type(tmp_path):
12281223 channels_data ["type" ][ch_idx ] = "FOOBAR"
12291224 _to_tsv (data = channels_data , fname = channels_tsv_path )
12301225
1231- with (
1232- pytest .warns (RuntimeWarning , match = 'will be set to "misc"' ),
1233- ):
1226+ with (pytest .warns (RuntimeWarning , match = 'will be set to "misc"' ),):
12341227 raw = read_raw_bids (bids_path )
12351228
12361229 # Should be a 'misc' channel.
@@ -1480,9 +1473,10 @@ def test_events_file_to_annotation_kwargs(tmp_path):
14801473 # ---------------- plain read --------------------------------------------
14811474 df = pd .read_csv (events_fname , sep = "\t " )
14821475 ev_kwargs = events_file_to_annotation_kwargs (events_fname = events_fname )
1483- assert (ev_kwargs ["onset" ] == df ["onset" ].values ).all ()
1484- assert (ev_kwargs ["duration" ] == df ["duration" ].values ).all ()
1485- assert (ev_kwargs ["description" ] == df ["trial_type" ].values ).all ()
1476+
1477+ np .testing .assert_equal (ev_kwargs ["onset" ], df ["onset" ].values )
1478+ np .testing .assert_equal (ev_kwargs ["duration" ], df ["duration" ].values )
1479+ np .testing .assert_equal (ev_kwargs ["description" ], df ["trial_type" ].values )
14861480
14871481 # ---------------- filtering out n/a values ------------------------------
14881482 tmp_tsv_file = tmp_path / "events.tsv"
@@ -1528,16 +1522,17 @@ def test_events_file_to_annotation_kwargs(tmp_path):
15281522 ) # now idx=0, as first row is filtered out
15291523
15301524 # ---------------- default if missing trial_type ------------------------
1531- tmp_tsv_file = tmp_path / "events.tsv"
15321525 dext .drop (columns = "trial_type" ).to_csv (tmp_tsv_file , sep = "\t " , index = False )
15331526
15341527 ev_kwargs_default = events_file_to_annotation_kwargs (events_fname = tmp_tsv_file )
1535- assert (ev_kwargs_default ["onset" ] == dext_f ["onset" ].astype (float ).values ).all ()
1536- assert (
1537- ev_kwargs_default ["duration" ]
1538- == dext_f ["duration" ].replace ("n/a" , "0.0" ).astype (float ).values
1539- ).all ()
1540- assert (
1541- np .sort (np .unique (ev_kwargs_default ["description" ]))
1542- == np .sort (dext_f ["value" ].unique ())
1543- ).all ()
1528+ np .testing .assert_array_equal (
1529+ ev_kwargs_default ["onset" ], dext_f ["onset" ].astype (float ).values
1530+ )
1531+ np .testing .assert_array_equal (
1532+ ev_kwargs_default ["duration" ],
1533+ dext_f ["duration" ].replace ("n/a" , "0.0" ).astype (float ).values ,
1534+ )
1535+ np .testing .assert_array_equal (
1536+ np .sort (np .unique (ev_kwargs_default ["description" ])),
1537+ np .sort (dext_f ["value" ].unique ()),
1538+ )
0 commit comments