|
4 | 4 |
|
5 | 5 | import itertools as itt |
6 | 6 | import sys |
7 | | -from contextlib import nullcontext |
8 | 7 | from inspect import signature |
9 | 8 | from pathlib import Path |
10 | 9 |
|
@@ -802,11 +801,7 @@ def test_low_rank_methods(rank, raw_epochs_events): |
802 | 801 | empirical=(-15000, -5000), diagonal_fixed=(-700, -600), oas=(-700, -600) |
803 | 802 | ), |
804 | 803 | } |
805 | | - if rank is None: |
806 | | - ctx = pytest.warns(RuntimeWarning, match="Too few samples") |
807 | | - else: |
808 | | - ctx = nullcontext() |
809 | | - with ctx: |
| 804 | + with pytest.warns(RuntimeWarning, match="Too few samples"): |
810 | 805 | covs = compute_covariance( |
811 | 806 | epochs, method=methods, return_estimators=True, rank=rank, verbose=True |
812 | 807 | ) |
@@ -858,7 +853,8 @@ def test_low_rank_cov(raw_epochs_events): |
858 | 853 | epochs_meg, method="oas", rank="full", verbose="error" |
859 | 854 | ) |
860 | 855 | assert _cov_rank(cov_full, epochs_meg.info) == 306 |
861 | | - cov_dict = compute_covariance(epochs_meg, method="oas", rank=dict(meg=306)) |
| 856 | + with pytest.warns(RuntimeWarning, match="few samples"): |
| 857 | + cov_dict = compute_covariance(epochs_meg, method="oas", rank=dict(meg=306)) |
862 | 858 | assert _cov_rank(cov_dict, epochs_meg.info) == 306 |
863 | 859 | assert_allclose(cov_full["data"], cov_dict["data"]) |
864 | 860 | cov_dict = compute_covariance( |
|
0 commit comments