Skip to content

Commit

Permalink
Warn user if using power law without constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Aug 4, 2023
1 parent bd5fc10 commit ca6e959
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pysr/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def _process_constraints(binary_operators, unary_operators, constraints):
constraints[op] = -1
for op in binary_operators:
if op not in constraints:
if op in ["^", "pow"]:
# Warn user that they should set up constraints
warnings.warn(
"You are using the `^` operator, but have not set up `constraints` for it. "
"This may lead to overly complex expressions. "
"One typical constraint is to use `constraints={..., '^': (-1, 1)}`, which "
"will allow arbitrary-complexity base (-1) but only powers such as "
"a constant or variable (1). "
"For more tips, please see https://astroautomata.com/PySR/tuning/"
)
constraints[op] = (-1, -1)
if op in ["plus", "sub", "+", "-"]:
if constraints[op][0] != constraints[op][1]:
Expand Down

0 comments on commit ca6e959

Please sign in to comment.