From cf8f7fbf87174e050b2933bfbc55c1e3e1c8b5e1 Mon Sep 17 00:00:00 2001 From: Matthias Schmidtblaicher Date: Thu, 15 Feb 2024 10:23:36 +0100 Subject: [PATCH] add future warnings on breaking changes in 3.0.0 --- CHANGELOG.rst | 1 + src/glum/_glm.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c42bde02..434ced32 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,7 @@ Unreleased - Require Python>=3.9 in line with `NEP 29 `_ - Build and test with Python 3.12 in CI. - Added line search stopping criterion for tiny loss improvements based on gradient information. +- Added warnings about breaking changes in future versions. 2.6.0 - 2023-09-05 ------------------ diff --git a/src/glum/_glm.py b/src/glum/_glm.py index 5582b893..54f3fda6 100644 --- a/src/glum/_glm.py +++ b/src/glum/_glm.py @@ -727,6 +727,11 @@ def __init__( robust: bool = True, expected_information: bool = False, ): + warnings.warn( + "Arguments to :class:`GeneralizedLinearRegressorBase`, :class:`GeneralizedLinearRegressor` ", + "and :class:`GeneralizedLinearRegressorCV` will become keyword-only in 3.0.0.", + FutureWarning, + ) self.l1_ratio = l1_ratio self.P1 = P1 self.P2 = P2 @@ -1133,6 +1138,10 @@ def report_diagnostics( custom_columns : iterable, optional (default=None) Print only the specified columns. """ + warnings.warn( + "Arguments to `report_diagnostics` will become keyword-only in 3.0.0.", + FutureWarning, + ) diagnostics = self.get_formatted_diagnostics(full_report, custom_columns) if isinstance(diagnostics, str): print(diagnostics) @@ -1159,6 +1168,10 @@ def get_formatted_diagnostics( custom_columns : iterable, optional (default=None) Print only the specified columns. """ + warnings.warn( + "Arguments to `get_formatted_diagnostics` will become keyword-only in 3.0.0.", + FutureWarning, + ) if not hasattr(self, "diagnostics_"): to_print = "Model has not been fit, so no diagnostics exist." return to_print @@ -1236,6 +1249,10 @@ def linear_predictor( array, shape (n_samples, n_alphas) The linear predictor. """ + warnings.warn( + "Arguments to `linear_predictor` other than `X` and `offset` will become keyword-only in 3.0.0.", + FutureWarning, + ) check_is_fitted(self, "coef_") if (alpha is not None) and (alpha_index is not None): @@ -1315,6 +1332,10 @@ def predict( array, shape (n_samples, n_alphas) Predicted values times ``sample_weight``. """ + warnings.warn( + "Arguments to `predict` other than `X`, ``sample_weight`, and `offset` will become keyword-only in 3.0.0.", + FutureWarning, + ) if isinstance(X, pd.DataFrame) and hasattr(self, "feature_dtypes_"): X = _align_df_categories(X, self.feature_dtypes_) @@ -1390,6 +1411,11 @@ def coef_table( pandas.DataFrame A table of the regression results. """ + warnings.warn( + "Arguments to `coef_table` other than `X`, `y`, `sample_weight`, and `offset` " + "will become keyword-only in 3.0.0.", + FutureWarning, + ) if self.fit_intercept: names = ["intercept"] + list(self.feature_names_) beta = np.concatenate([[self.intercept_], self.coef_]) @@ -1498,6 +1524,11 @@ def wald_test( WaldTestResult NamedTuple with test statistic, p-value, and degrees of freedom. """ + warnings.warn( + "Arguments to `coef_table` other than `X`, `y`, `sample_weight`, and `offset` " + "will become keyword-only in 3.0.0.", + FutureWarning, + ) num_lhs_specs = sum([R is not None, features is not None]) if num_lhs_specs != 1: @@ -1890,6 +1921,11 @@ def covariance_matrix( Cambridge university press """ + warnings.warn( + "Arguments to `covaria ce_matrix` other than `X`, `y`, `sample_weight`, and `offset` " + "will become keyword-only in 3.0.0.", + FutureWarning, + ) self.covariance_matrix_: Union[np.ndarray, None] if robust is None: @@ -2763,6 +2799,9 @@ def __init__( robust: bool = True, expected_information: bool = False, ): + warnings.warn( + "The default value of `alpha` will become `0` in 3.0.0.", FutureWarning + ) self.alphas = alphas self.alpha = alpha super().__init__( @@ -2895,6 +2934,11 @@ def fit( ------- self """ + warnings.warn( + "Arguments to `fit` other than `X`, `y`, `sample_weight`, and `offset` " + "will become keyword-only in 3.0.0.", + FutureWarning, + ) self._validate_hyperparameters()