##// END OF EJS Templates
Merge pull request #1773 from asmeurer/sympy_set...
Min RK -
r7260:dbad0513 merge
parent child Browse files
Show More
@@ -62,7 +62,7 b' def can_print_latex(o):'
62 62 can be printed with LaTeX.
63 63 """
64 64 import sympy
65 if isinstance(o, (list, tuple)):
65 if isinstance(o, (list, tuple, set, frozenset)):
66 66 return all(can_print_latex(i) for i in o)
67 67 elif isinstance(o, dict):
68 68 return all((isinstance(i, basestring) or can_print_latex(i)) and can_print_latex(o[i]) for i in o)
@@ -85,13 +85,22 b' _loaded = False'
85 85
86 86 def load_ipython_extension(ip):
87 87 """Load the extension in IPython."""
88 import sympy
88 89 global _loaded
89 90 if not _loaded:
90 91 plaintext_formatter = ip.display_formatter.formatters['text/plain']
91 92
92 for cls in (object, set, frozenset, str):
93 # set and frozen set are currently broken with SymPy's latex()
94 # function. See http://code.google.com/p/sympy/issues/detail?id=3062.
93 for cls in (object, str):
94 plaintext_formatter.for_type(cls, print_basic_unicode)
95
96 printable_containers = [list, tuple]
97
98 # set and frozen set were broken with SymPy's latex() function, but
99 # was fixed in the 0.7.1-git development version. See
100 # http://code.google.com/p/sympy/issues/detail?id=3062.
101 if sympy.__version__ > '0.7.1':
102 printable_containers += [set, frozenset]
103 else:
95 104 plaintext_formatter.for_type(cls, print_basic_unicode)
96 105
97 106 plaintext_formatter.for_type_by_name(
@@ -106,7 +115,7 b' def load_ipython_extension(ip):'
106 115 png_formatter.for_type_by_name(
107 116 'sympy.core.basic', 'Basic', print_png
108 117 )
109 for cls in (list, tuple, dict, int, long, float):
118 for cls in [dict, int, long, float] + printable_containers:
110 119 png_formatter.for_type(cls, print_png)
111 120
112 121 latex_formatter = ip.display_formatter.formatters['text/latex']
@@ -117,7 +126,7 b' def load_ipython_extension(ip):'
117 126 'sympy.matrices.matrices', 'Matrix', print_latex
118 127 )
119 128
120 for cls in (list, tuple):
129 for cls in printable_containers:
121 130 # Use LaTeX only if every element is printable by latex
122 131 latex_formatter.for_type(cls, print_latex)
123 132
General Comments 0
You need to be logged in to leave comments. Login now