Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
f0c64cb
1
Parent(s):
3dff82f
Move binary_operator assertion to after they are defined
Browse files- pysr/sr.py +2 -5
pysr/sr.py
CHANGED
@@ -132,15 +132,12 @@ def _maybe_create_inline_operators(binary_operators, unary_operators):
|
|
132 |
|
133 |
def _check_assertions(
|
134 |
X,
|
135 |
-
binary_operators,
|
136 |
-
unary_operators,
|
137 |
use_custom_variable_names,
|
138 |
variable_names,
|
139 |
weights,
|
140 |
y,
|
141 |
):
|
142 |
# Check for potential errors before they happen
|
143 |
-
assert len(unary_operators) + len(binary_operators) > 0
|
144 |
assert len(X.shape) == 2
|
145 |
assert len(y.shape) in [1, 2]
|
146 |
assert X.shape[0] == y.shape[0]
|
@@ -1125,6 +1122,8 @@ class PySRRegressor(BaseEstimator, RegressorMixin, MultiOutputMixin):
|
|
1125 |
elif isinstance(unary_operators, str):
|
1126 |
unary_operators = [unary_operators]
|
1127 |
|
|
|
|
|
1128 |
if constraints is None:
|
1129 |
constraints = {}
|
1130 |
|
@@ -1436,8 +1435,6 @@ class PySRRegressor(BaseEstimator, RegressorMixin, MultiOutputMixin):
|
|
1436 |
|
1437 |
_check_assertions(
|
1438 |
X,
|
1439 |
-
self.binary_operators,
|
1440 |
-
self.unary_operators,
|
1441 |
use_custom_variable_names,
|
1442 |
variable_names,
|
1443 |
weights,
|
|
|
132 |
|
133 |
def _check_assertions(
|
134 |
X,
|
|
|
|
|
135 |
use_custom_variable_names,
|
136 |
variable_names,
|
137 |
weights,
|
138 |
y,
|
139 |
):
|
140 |
# Check for potential errors before they happen
|
|
|
141 |
assert len(X.shape) == 2
|
142 |
assert len(y.shape) in [1, 2]
|
143 |
assert X.shape[0] == y.shape[0]
|
|
|
1122 |
elif isinstance(unary_operators, str):
|
1123 |
unary_operators = [unary_operators]
|
1124 |
|
1125 |
+
assert len(unary_operators) + len(binary_operators) > 0
|
1126 |
+
|
1127 |
if constraints is None:
|
1128 |
constraints = {}
|
1129 |
|
|
|
1435 |
|
1436 |
_check_assertions(
|
1437 |
X,
|
|
|
|
|
1438 |
use_custom_variable_names,
|
1439 |
variable_names,
|
1440 |
weights,
|