MilesCranmer commited on
Commit
ca6e959
1 Parent(s): bd5fc10

Warn user if using power law without constraint

Browse files
Files changed (1) hide show
  1. pysr/sr.py +10 -0
pysr/sr.py CHANGED
@@ -104,6 +104,16 @@ def _process_constraints(binary_operators, unary_operators, constraints):
104
  constraints[op] = -1
105
  for op in binary_operators:
106
  if op not in constraints:
 
 
 
 
 
 
 
 
 
 
107
  constraints[op] = (-1, -1)
108
  if op in ["plus", "sub", "+", "-"]:
109
  if constraints[op][0] != constraints[op][1]:
 
104
  constraints[op] = -1
105
  for op in binary_operators:
106
  if op not in constraints:
107
+ if op in ["^", "pow"]:
108
+ # Warn user that they should set up constraints
109
+ warnings.warn(
110
+ "You are using the `^` operator, but have not set up `constraints` for it. "
111
+ "This may lead to overly complex expressions. "
112
+ "One typical constraint is to use `constraints={..., '^': (-1, 1)}`, which "
113
+ "will allow arbitrary-complexity base (-1) but only powers such as "
114
+ "a constant or variable (1). "
115
+ "For more tips, please see https://astroautomata.com/PySR/tuning/"
116
+ )
117
  constraints[op] = (-1, -1)
118
  if op in ["plus", "sub", "+", "-"]:
119
  if constraints[op][0] != constraints[op][1]: