Test apply function verbosity.
()
| 33 | |
| 34 | @pytest.mark.slowtest |
| 35 | def test_apply_function_verbose(): |
| 36 | """Test apply function verbosity.""" |
| 37 | n_chan = 2 |
| 38 | n_times = 3 |
| 39 | ch_names = [str(ii) for ii in range(n_chan)] |
| 40 | raw = RawArray(np.zeros((n_chan, n_times)), create_info(ch_names, 1.0, "mag")) |
| 41 | # test return types in both code paths (parallel / 1 job) |
| 42 | with pytest.raises(TypeError, match="Return value must be an ndarray"): |
| 43 | raw.apply_function(bad_1) |
| 44 | with pytest.raises(ValueError, match="Return data must have shape"): |
| 45 | raw.apply_function(bad_2) |
| 46 | with pytest.raises(TypeError, match="Return value must be an ndarray"): |
| 47 | raw.apply_function(bad_1, n_jobs=2) |
| 48 | with pytest.raises(ValueError, match="Return data must have shape"): |
| 49 | raw.apply_function(bad_2, n_jobs=2) |
| 50 | |
| 51 | # test return type when `channel_wise=False` |
| 52 | raw.apply_function(printer, channel_wise=False) |
| 53 | with pytest.raises(TypeError, match="Return value must be an ndarray"): |
| 54 | raw.apply_function(bad_1, channel_wise=False) |
| 55 | with pytest.raises(ValueError, match="Return data must have shape"): |
| 56 | raw.apply_function(bad_3, channel_wise=False) |
| 57 | |
| 58 | # check our arguments |
| 59 | with catch_logging() as sio: |
| 60 | out = raw.apply_function(printer, verbose=False) |
| 61 | assert len(sio.getvalue(close=False)) == 0 |
| 62 | assert out is raw |
| 63 | raw.apply_function(printer, verbose=True) |
| 64 | assert sio.getvalue().count("\n") == n_chan |
| 65 | |
| 66 | |
| 67 | def test_apply_function_ch_access(): |
nothing calls this directly
no test coverage detected