Skip to content

Commit ed946f0

Browse files
test: backport sklearn estimator skip handling
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
1 parent 295e5a3 commit ed946f0

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

pysr/sr.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,16 +2662,23 @@ def get_hof(self, search_output=None) -> pd.DataFrame | list[pd.DataFrame]:
26622662

26632663
equation_file_contents = cast(List[pd.DataFrame], self.equation_file_contents_)
26642664

2665-
ret_outputs = [
2666-
pd.concat(
2667-
[
2668-
output,
2669-
*([calculate_scores(output)] if self.loss_scale == "log" else []),
2670-
self.expression_spec_.create_exports(
2671-
self, output, search_output, i if self.nout_ > 1 else None
2672-
),
2673-
],
2674-
axis=1,
2665+
ret_outputs: list[pd.DataFrame] = [
2666+
cast(
2667+
pd.DataFrame,
2668+
pd.concat(
2669+
[
2670+
output,
2671+
*(
2672+
[calculate_scores(output)]
2673+
if self.loss_scale == "log"
2674+
else []
2675+
),
2676+
self.expression_spec_.create_exports(
2677+
self, output, search_output, i if self.nout_ > 1 else None
2678+
),
2679+
],
2680+
axis=1,
2681+
),
26752682
)
26762683
for i, output in enumerate(equation_file_contents)
26772684
]

pysr/test/test_main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,8 @@ def test_scikit_learn_compatibility(self):
10221022
warnings.simplefilter("ignore")
10231023
check(model)
10241024
print("Passed", check.func.__name__)
1025+
except unittest.SkipTest as exc:
1026+
print("Skipped", check.func.__name__, "with:", str(exc))
10251027
except Exception:
10261028
error_message = str(traceback.format_exc())
10271029
exception_messages.append(

0 commit comments

Comments
 (0)