##// END OF EJS Templates
removed skipif decorators from non-tests
Paul Ivanov -
Show More
@@ -1,72 +1,70 b''
1 1 """A print function that pretty prints sympy Basic objects.
2 2
3 3 Authors:
4 4 * Brian Granger
5 5 """
6 6 #-----------------------------------------------------------------------------
7 7 # Copyright (C) 2008-2011 The IPython Development Team
8 8 #
9 9 # Distributed under the terms of the BSD License. The full license is in
10 10 # the file COPYING, distributed as part of this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from IPython.lib.latextools import latex_to_png
18 18 from IPython.testing import decorators as dec
19 # use @dec.skipif_not_sympy to skip tests requiring sympy
19 20
20 21 try:
21 22 from sympy import pretty, latex
22 23 except ImportError:
23 24 pass
24 25
25 26
26 27 #-----------------------------------------------------------------------------
27 28 # Definitions of magic functions for use with IPython
28 29 #-----------------------------------------------------------------------------
29 30
30 @dec.skipif_not_sympy
31 31 def print_basic_unicode(o, p, cycle):
32 32 """A function to pretty print sympy Basic objects."""
33 33 if cycle:
34 34 return p.text('Basic(...)')
35 35 out = pretty(o, use_unicode=True)
36 36 if '\n' in out:
37 37 p.text(u'\n')
38 38 p.text(out)
39 39
40 40
41 @dec.skipif_not_sympy
42 41 def print_png(o):
43 42 """A funciton to display sympy expression using LaTex -> PNG."""
44 43 s = latex(o, mode='inline')
45 44 # mathtext does not understand certain latex flags, so we try to replace
46 45 # them with suitable subs.
47 46 s = s.replace('\\operatorname','')
48 47 s = s.replace('\\overline', '\\bar')
49 48 png = latex_to_png(s, encode=True)
50 49 return png
51 50
52 51 _loaded = False
53 52
54 @dec.skipif_not_sympy
55 53 def load_ipython_extension(ip):
56 54 """Load the extension in IPython."""
57 55 global _loaded
58 56 if not _loaded:
59 57 plaintext_formatter = ip.display_formatter.formatters['text/plain']
60 58 plaintext_formatter.for_type_by_name(
61 59 'sympy.core.basic', 'Basic', print_basic_unicode
62 60 )
63 61 plaintext_formatter.for_type_by_name(
64 62 'sympy.matrices.matrices', 'Matrix', print_basic_unicode
65 63 )
66 64
67 65 png_formatter = ip.display_formatter.formatters['image/png']
68 66 png_formatter.for_type_by_name(
69 67 'sympy.core.basic', 'Basic', print_png
70 68 )
71 69 _loaded = True
72 70
General Comments 0
You need to be logged in to leave comments. Login now