From 53f76472e19a597e15a924df71043332256bc405 Mon Sep 17 00:00:00 2001 From: lbittarello Date: Mon, 16 Mar 2026 10:51:06 +0000 Subject: [PATCH] Unhelpful warning --- src/glum/_glm.py | 4 +++- tests/glm/test_glm_regressor.py | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/glum/_glm.py b/src/glum/_glm.py index 8c9e73e9..66398940 100644 --- a/src/glum/_glm.py +++ b/src/glum/_glm.py @@ -1972,7 +1972,9 @@ def _set_up_and_check_fit_args( # Backwards compatibility if isinstance(X, pd.DataFrame): - self.feature_dtypes_ = X.dtypes.to_dict() + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + self.feature_dtypes_ = X.dtypes.to_dict() X = cast(nw.DataFrame, nw.from_native(X)) # avoid inferring `Never` diff --git a/tests/glm/test_glm_regressor.py b/tests/glm/test_glm_regressor.py index 351d1077..30f7bcfd 100644 --- a/tests/glm/test_glm_regressor.py +++ b/tests/glm/test_glm_regressor.py @@ -1212,10 +1212,11 @@ def test_predict_list_categorical(): df["x"] = df["x"].astype("category") df["y"] = df["x"].map({v: k + 1 for k, v in enumerate(letters)}) - regressor = GeneralizedLinearRegressor(alpha=[0, 2], alpha_search=True) - regressor = regressor.fit(df[["x"]], df["y"]) - - candidate = regressor.predict(df[["x"]], alpha=0) + candidate = ( + GeneralizedLinearRegressor(alpha=[0, 2], alpha_search=True, fit_intercept=False) + .fit(df[["x"]], df["y"]) + .predict(df[["x"]], alpha=0) + ) np.testing.assert_allclose(candidate, df["y"])