From c7cea75d4e9b1184f387880577d97497fca5c5f7 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 30 Jul 2023 16:06:36 -0400 Subject: [PATCH] Fix compat with old scikit-learn versions --- pysr/sr.py | 12 +++++++++++- pysr/version.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pysr/sr.py b/pysr/sr.py index 5fd76326f..1fc327b6f 100644 --- a/pysr/sr.py +++ b/pysr/sr.py @@ -1438,7 +1438,7 @@ def _validate_and_set_fit_params( weights = check_array(weights, ensure_2d=False) check_consistent_length(weights, y) X, y = self._validate_data(X=X, y=y, reset=True, multi_output=True) - self.feature_names_in_ = _check_feature_names_in( + self.feature_names_in_ = _safe_check_feature_names_in( self, variable_names, generate_names=False ) @@ -2549,3 +2549,13 @@ def _subscriptify(i: int) -> str: For example, 123 -> "₁₂₃". """ return "".join([chr(0x2080 + int(c)) for c in str(i)]) + + +def _safe_check_feature_names_in(self, variable_names, generate_names=True): + """_check_feature_names_in with compat for old versions.""" + try: + return _check_feature_names_in( + self, variable_names, generate_names=generate_names + ) + except TypeError: + return _check_feature_names_in(self, variable_names) diff --git a/pysr/version.py b/pysr/version.py index 530fee252..b61b5849f 100644 --- a/pysr/version.py +++ b/pysr/version.py @@ -1,2 +1,2 @@ -__version__ = "0.15.0" +__version__ = "0.15.1" __symbolic_regression_jl_version__ = "0.21.3"