Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
4f97146
1
Parent(s):
a628552
Make latex table private function
Browse files- pysr/sr.py +1 -1
- test/test.py +4 -4
pysr/sr.py
CHANGED
@@ -2000,7 +2000,7 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
2000 |
return ret_outputs
|
2001 |
return ret_outputs[0]
|
2002 |
|
2003 |
-
def
|
2004 |
"""Create a LaTeX/booktabs table for all, or some, of the equations.
|
2005 |
|
2006 |
Parameters
|
|
|
2000 |
return ret_outputs
|
2001 |
return ret_outputs[0]
|
2002 |
|
2003 |
+
def _latex_table(self, indices=None, precision=3, include_score=False):
|
2004 |
"""Create a LaTeX/booktabs table for all, or some, of the equations.
|
2005 |
|
2006 |
Parameters
|
test/test.py
CHANGED
@@ -538,7 +538,7 @@ class TestLaTeXTable(unittest.TestCase):
|
|
538 |
model = manually_create_model(equations)
|
539 |
|
540 |
# Regular table:
|
541 |
-
latex_table_str = model.
|
542 |
middle_part = r"""
|
543 |
$x_{0}$ & $1$ & $1.05$ \\
|
544 |
$\cos{\left(x_{0} \right)}$ & $2$ & $0.0232$ \\
|
@@ -548,7 +548,7 @@ class TestLaTeXTable(unittest.TestCase):
|
|
548 |
self.assertEqual(latex_table_str, true_latex_table_str)
|
549 |
|
550 |
# Different precision:
|
551 |
-
latex_table_str = model.
|
552 |
middle_part = r"""
|
553 |
$x_{0}$ & $1$ & $1.0520$ \\
|
554 |
$\cos{\left(x_{0} \right)}$ & $2$ & $0.023150$ \\
|
@@ -558,7 +558,7 @@ class TestLaTeXTable(unittest.TestCase):
|
|
558 |
self.assertEqual(latex_table_str, self.create_true_latex(middle_part))
|
559 |
|
560 |
# Including score:
|
561 |
-
latex_table_str = model.
|
562 |
middle_part = r"""
|
563 |
$x_{0}$ & $1$ & $1.05$ & $0.0$ \\
|
564 |
$\cos{\left(x_{0} \right)}$ & $2$ & $0.0232$ & $3.82$ \\
|
@@ -568,7 +568,7 @@ class TestLaTeXTable(unittest.TestCase):
|
|
568 |
self.assertEqual(latex_table_str, true_latex_table_str)
|
569 |
|
570 |
# Only last equation:
|
571 |
-
latex_table_str = model.
|
572 |
middle_part = r"""
|
573 |
$x_{0} + x_{1} - \cos{\left(x_{0} x_{1} \right)}$ & $8$ & $1.12 \cdot 10^{-15}$ \\
|
574 |
"""
|
|
|
538 |
model = manually_create_model(equations)
|
539 |
|
540 |
# Regular table:
|
541 |
+
latex_table_str = model._latex_table()
|
542 |
middle_part = r"""
|
543 |
$x_{0}$ & $1$ & $1.05$ \\
|
544 |
$\cos{\left(x_{0} \right)}$ & $2$ & $0.0232$ \\
|
|
|
548 |
self.assertEqual(latex_table_str, true_latex_table_str)
|
549 |
|
550 |
# Different precision:
|
551 |
+
latex_table_str = model._latex_table(precision=5)
|
552 |
middle_part = r"""
|
553 |
$x_{0}$ & $1$ & $1.0520$ \\
|
554 |
$\cos{\left(x_{0} \right)}$ & $2$ & $0.023150$ \\
|
|
|
558 |
self.assertEqual(latex_table_str, self.create_true_latex(middle_part))
|
559 |
|
560 |
# Including score:
|
561 |
+
latex_table_str = model._latex_table(include_score=True)
|
562 |
middle_part = r"""
|
563 |
$x_{0}$ & $1$ & $1.05$ & $0.0$ \\
|
564 |
$\cos{\left(x_{0} \right)}$ & $2$ & $0.0232$ & $3.82$ \\
|
|
|
568 |
self.assertEqual(latex_table_str, true_latex_table_str)
|
569 |
|
570 |
# Only last equation:
|
571 |
+
latex_table_str = model._latex_table(indices=[2])
|
572 |
middle_part = r"""
|
573 |
$x_{0} + x_{1} - \cos{\left(x_{0} x_{1} \right)}$ & $8$ & $1.12 \cdot 10^{-15}$ \\
|
574 |
"""
|