Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TableForm: Add tests, remove array's links, clear noise.

  • Loading branch information...
commit a08ee71203ab68f6aca0a4506643158cd92bda21 1 parent d77a730
@goodok authored
View
1  sympy/core/containers.py
@@ -203,4 +203,3 @@ def __contains__(self, key):
def __lt__(self, other):
return self.args < other.args
-
View
3  sympy/core/tests/test_containers.py
@@ -1,5 +1,4 @@
-from sympy import (Matrix, Tuple, symbols, sympify, Basic, Dict, S, FiniteSet,
- array)
+from sympy import Matrix, Tuple, symbols, sympify, Basic, Dict, S, FiniteSet
from sympy.core.containers import tuple_wrapper
from sympy.utilities.pytest import raises
from sympy.core.compatibility import is_sequence, iterable
View
65 sympy/printing/tests/test_tableform.py
@@ -1,18 +1,73 @@
-from sympy import TableForm, array
+from sympy import TableForm, S
+from sympy.printing.latex import latex
+from sympy.abc import x
+from sympy.functions.elementary.miscellaneous import sqrt
+from sympy.functions.elementary.trigonometric import sin
def test_TableForm():
- a = array([4, 2, 3])
- s = str(TableForm(zip(a, a**3)))
-
s = str(TableForm([["a", "b"], ["c", "d"], ["e", "f"]],
headings="automatic"))
- s = str(TableForm([["a", "b"], ["c", "d"], ["e", "f"]],
+ assert s == """\
+ | 1 2\n\
+------\n\
+1 | a b\n\
+2 | c d\n\
+3 | e f\n\
+"""
+ s = str(TableForm([[x**2, "b"], ["c", x**2], ["e", "f"]],
headings=("automatic", None)))
+ assert s == """\
+1 | x**2 b \n\
+2 | c x**2\n\
+3 | e f \n\
+"""
s = str(TableForm([["a", "b"], ["c", "d"], ["e", "f"]],
headings=(None, "automatic")))
+ assert s == """\
+1 2\n\
+--\n\
+a b\n\
+c d\n\
+e f\n\
+"""
s = str(TableForm([[5, 7], [4, 2], [10, 3]],
headings=[["Group A", "Group B", "Group C"], ["y1", "y2"]]))
+ assert s == """\
+ | y1 y2\n\
+--------------\n\
+Group A | 5 7 \n\
+Group B | 4 2 \n\
+Group C | 10 3 \n\
+"""
s = str(TableForm([[5, 7], [4, 2], [10, 3]],
headings=[["Group A", "Group B", "Group C"], ["y1", "y2"]],
alignment="right"))
+ assert s == """\
+ | y1 y2\n\
+--------------\n\
+Group A | 5 7\n\
+Group B | 4 2\n\
+Group C | 10 3\n\
+"""
+
+ s = latex(TableForm([["a", x**3], ["c", S(1)/4], [sqrt(x), sin(x**2)]],
+ headings=("automatic", "automatic")))
+ assert s == """\
+\\begin{tabular}{c c c}\n\
+ & 1 & 2 \\\\\n\
+\\hline\n\
+1 & $a$ & $x^{3}$ \\\\\n\
+2 & $c$ & $\\frac{1}{4}$ \\\\\n\
+3 & $\\sqrt{x}$ & $\\sin{\\left (x^{2} \\right )}$ \\\\\n\
+\\end{tabular}\
+"""
+
+ s = latex(TableForm([["a", x**3], ["c", S(1)/4], [sqrt(x), sin(x**2)]]))
+ assert s == """\
+\\begin{tabular}{c c}\n\
+$a$ & $x^{3}$ \\\\\n\
+$c$ & $\\frac{1}{4}$ \\\\\n\
+$\\sqrt{x}$ & $\\sin{\\left (x^{2} \\right )}$ \\\\\n\
+\\end{tabular}\
+"""
Please sign in to comment.
Something went wrong with that request. Please try again.