Skip to content

Commit

Permalink
Merge pull request #393 from MilesCranmer/MilesCranmer/issue392
Browse files Browse the repository at this point in the history
Fix compat with old scikit-learn versions
  • Loading branch information
MilesCranmer authored Jul 30, 2023
2 parents 875c5aa + c7cea75 commit 3a9acd3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion pysr/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion pysr/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.15.0"
__version__ = "0.15.1"
__symbolic_regression_jl_version__ = "0.21.3"

0 comments on commit 3a9acd3

Please sign in to comment.