Skip to content

Commit

Permalink
FIX: 2D
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Oct 30, 2024
1 parent 7c917c8 commit f272c03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions mne/stats/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,10 @@ def solver(X, y):
coefs = solver(X, data.T)
if coefs.shape[0] != data.shape[0]:
raise ValueError(
"solver output has unexcepted shape. Supply a "
f"solver output has unexcepted shape {coefs.shape}. Supply a "
"function that returns coefficients in the form "
"(n_targets, n_features), where targets == channels."
"(n_targets, n_features), where "
f"n_targets == n_channels == {data.shape[0]}."
)

# construct Evoked objects to be returned from output
Expand Down
4 changes: 3 additions & 1 deletion mne/stats/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def test_continuous_regression_with_overlap():
from sklearn.linear_model import ridge_regression

def solver(X, y):
return ridge_regression(X, y, alpha=0.0, solver="cholesky")
# Newer scikit-learn returns 1D array for ridge_regression, so ensure
# 2D output
return np.atleast_2d(ridge_regression(X, y, alpha=0.0, solver="cholesky"))

assert_allclose(
effect,
Expand Down

0 comments on commit f272c03

Please sign in to comment.