Skip to content

Commit

Permalink
add future warnings on breaking changes in 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasSchmidtblaicherQC committed Feb 15, 2024
1 parent 461de0f commit cf8f7fb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Unreleased
- Require Python>=3.9 in line with `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table>`_
- 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
------------------
Expand Down
44 changes: 44 additions & 0 deletions src/glum/_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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_)

Expand Down Expand Up @@ -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_])
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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__(
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit cf8f7fb

Please sign in to comment.