MCPcopy
hub / github.com/mne-tools/mne-python / _test_raw_reader

Function _test_raw_reader

mne/io/tests/test_raw.py:102–535  ·  view source on GitHub ↗

Test reading, writing and slicing of raw classes. Parameters ---------- reader : function Function to test. test_preloading : bool Whether not preloading is implemented for the reader. If True, both cases and memory mapping to file are tested. test_kwargs

(
    reader,
    test_preloading=True,
    test_kwargs=True,
    boundary_decimal=2,
    test_scaling=True,
    test_rank=True,
    **kwargs,
)

Source from the content-addressed store, hash-verified

100
101
102def _test_raw_reader(
103 reader,
104 test_preloading=True,
105 test_kwargs=True,
106 boundary_decimal=2,
107 test_scaling=True,
108 test_rank=True,
109 **kwargs,
110):
111 """Test reading, writing and slicing of raw classes.
112
113 Parameters
114 ----------
115 reader : function
116 Function to test.
117 test_preloading : bool
118 Whether not preloading is implemented for the reader. If True, both
119 cases and memory mapping to file are tested.
120 test_kwargs : dict
121 Test _init_kwargs support.
122 boundary_decimal : int
123 Number of decimals up to which the boundary should match.
124 **kwargs :
125 Arguments for the reader. Note: Do not use preload as kwarg.
126 Use ``test_preloading`` instead.
127
128 Returns
129 -------
130 raw : instance of Raw
131 A preloaded Raw object.
132 """
133 tempdir = _TempDir()
134 rng = np.random.RandomState(0)
135 montage = None
136 if "montage" in kwargs:
137 montage = kwargs["montage"]
138 del kwargs["montage"]
139 if test_preloading:
140 raw = reader(preload=True, **kwargs)
141 rep = repr(raw)
142 assert rep.count("<") == 1
143 assert rep.count(">") == 1
144 if montage is not None:
145 raw.set_montage(montage)
146 # don't assume the first is preloaded
147 buffer_fname = op.join(tempdir, "buffer")
148 picks = rng.permutation(np.arange(len(raw.ch_names) - 1))[:10]
149 picks = np.append(picks, len(raw.ch_names) - 1) # test trigger channel
150 bnd = min(int(round(raw.buffer_size_sec * raw.info["sfreq"])), raw.n_times)
151 slices = [
152 slice(0, bnd),
153 slice(bnd - 1, bnd),
154 slice(3, bnd),
155 slice(3, 300),
156 slice(None),
157 slice(1, bnd),
158 ]
159 if raw.n_times >= 2 * bnd: # at least two complete blocks

Callers 15

test_nsx_ver_31Function · 0.90
test_nsx_ver_22Function · 0.90
test_nsxFunction · 0.90
test_dataFunction · 0.90
test_file_likeFunction · 0.90
test_fif_filesFunction · 0.90
test_nihon_eegFunction · 0.90
test_eximia_nxeFunction · 0.90
test_io_set_rawFunction · 0.90
test_io_set_raw_2021Function · 0.90
test_neuralynxFunction · 0.90

Calls 15

_TempDirClass · 0.90
pick_typesFunction · 0.90
ProjectionClass · 0.90
_stamp_to_dtFunction · 0.90
concatenate_rawsFunction · 0.90
read_raw_fifFunction · 0.90
_get_valid_unitsFunction · 0.90
check_versionFunction · 0.90
_import_h5io_funcsFunction · 0.90
_writing_info_hdf5Function · 0.90
InfoClass · 0.90
object_diffFunction · 0.90

Tested by

no test coverage detected