Skip to content

Commit

Permalink
Move compatibility block after import
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmart committed Sep 9, 2024
1 parent 990ca83 commit 4f03276
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/glum/_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@
column_or_1d,
)

if hasattr(sklearn.utils.validation, "validate_data"):
validate_data = sklearn.utils.validation.validate_data
else:
validate_data = BaseEstimator._validate_data

if hasattr(sklearn.utils.validation, "_check_n_features"):
_check_n_features = sklearn.utils.validation._check_n_features
else:
_check_n_features = BaseEstimator._check_n_features


from ._distribution import (
BinomialDistribution,
ExponentialDispersionModel,
Expand Down Expand Up @@ -89,6 +78,16 @@
else:
keyword_finiteness = "ensure_all_finite"

if hasattr(sklearn.utils.validation, "validate_data"):
validate_data = sklearn.utils.validation.validate_data
else:
validate_data = BaseEstimator._validate_data

if hasattr(sklearn.utils.validation, "_check_n_features"):
_check_n_features = sklearn.utils.validation._check_n_features
else:
_check_n_features = BaseEstimator._check_n_features

_float_itemsize_to_dtype = {8: np.float64, 4: np.float32, 2: np.float16}

VectorLike = Union[np.ndarray, pd.api.extensions.ExtensionArray, pd.Index, pd.Series]
Expand Down

0 comments on commit 4f03276

Please sign in to comment.