From 4f032766a4384788aa97f099616f8fc5af4bcfdf Mon Sep 17 00:00:00 2001 From: Martin Stancsics Date: Mon, 9 Sep 2024 11:09:15 +0200 Subject: [PATCH] Move compatibility block after import --- src/glum/_glm.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/glum/_glm.py b/src/glum/_glm.py index 2ace19a8..0d962dd1 100644 --- a/src/glum/_glm.py +++ b/src/glum/_glm.py @@ -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, @@ -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]