Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
f544d25
1
Parent(s):
c915ce2
Move CallableEquation to bottom of docs
Browse files- pysr/sr.py +19 -17
pysr/sr.py
CHANGED
@@ -67,23 +67,6 @@ sympy_mappings = {
|
|
67 |
'gamma': lambda x : sympy.gamma(x),
|
68 |
}
|
69 |
|
70 |
-
class CallableEquation(object):
|
71 |
-
"""Simple wrapper for numpy lambda functions built with sympy"""
|
72 |
-
def __init__(self, sympy_symbols, eqn, selection=None):
|
73 |
-
self._sympy = eqn
|
74 |
-
self._sympy_symbols = sympy_symbols
|
75 |
-
self._selection = selection
|
76 |
-
self._lambda = lambdify(sympy_symbols, eqn)
|
77 |
-
|
78 |
-
def __repr__(self):
|
79 |
-
return f"PySRFunction(X=>{self._sympy})"
|
80 |
-
|
81 |
-
def __call__(self, X):
|
82 |
-
if self._selection is not None:
|
83 |
-
return self._lambda(*X[:, self._selection].T)
|
84 |
-
else:
|
85 |
-
return self._lambda(*X.T)
|
86 |
-
|
87 |
def pysr(X, y, weights=None,
|
88 |
binary_operators=None,
|
89 |
unary_operators=None,
|
@@ -922,3 +905,22 @@ def _yesno(question):
|
|
922 |
if ans == 'y':
|
923 |
return True
|
924 |
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
'gamma': lambda x : sympy.gamma(x),
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
def pysr(X, y, weights=None,
|
71 |
binary_operators=None,
|
72 |
unary_operators=None,
|
|
|
905 |
if ans == 'y':
|
906 |
return True
|
907 |
return False
|
908 |
+
|
909 |
+
|
910 |
+
class CallableEquation(object):
|
911 |
+
"""Simple wrapper for numpy lambda functions built with sympy"""
|
912 |
+
def __init__(self, sympy_symbols, eqn, selection=None):
|
913 |
+
self._sympy = eqn
|
914 |
+
self._sympy_symbols = sympy_symbols
|
915 |
+
self._selection = selection
|
916 |
+
self._lambda = lambdify(sympy_symbols, eqn)
|
917 |
+
|
918 |
+
def __repr__(self):
|
919 |
+
return f"PySRFunction(X=>{self._sympy})"
|
920 |
+
|
921 |
+
def __call__(self, X):
|
922 |
+
if self._selection is not None:
|
923 |
+
return self._lambda(*X[:, self._selection].T)
|
924 |
+
else:
|
925 |
+
return self._lambda(*X.T)
|
926 |
+
|