##// END OF EJS Templates
Use LaTeX to print various built-in types with the SymPy printing extension...
Use LaTeX to print various built-in types with the SymPy printing extension SymPy's latex() function supports printing lists, tuples, and dicts using latex notation (it uses bmatrix, pmatrix, and Bmatrix, respectively). This provides a more unified experience with SymPy functions that return these types (such as solve()). Also print ints, longs, and floats using LaTeX, to get a more unified printing experience (so that, e.g., `x/x` will print the same as just `1`). The string form can always be obtained by using `print`, or 2d unicode printing using pprint(). SymPy's latex() function doesn't treat set() or frosenset() correctly presently (see http://code.google.com/p/sympy/issues/detail?id=3062), so for the present, we leave those alone. Currently, the printing of lists, tuples, and dicts does not work correctly in the qtconsole.

File last commit:

r2640:93949c91
r6110:e21221cc
Show More
test_completion_lexer.py
47 lines | 1.4 KiB | text/x-python | PythonLexer
/ IPython / frontend / qt / console / tests / test_completion_lexer.py
# Standard library imports
import unittest
# System library imports
from pygments.lexers import CLexer, CppLexer, PythonLexer
# Local imports
from IPython.frontend.qt.console.completion_lexer import CompletionLexer
class TestCompletionLexer(unittest.TestCase):
def testPython(self):
""" Does the CompletionLexer work for Python?
"""
lexer = CompletionLexer(PythonLexer())
# Test simplest case.
self.assertEquals(lexer.get_context("foo.bar.baz"),
[ "foo", "bar", "baz" ])
# Test trailing period.
self.assertEquals(lexer.get_context("foo.bar."), [ "foo", "bar", "" ])
# Test with prompt present.
self.assertEquals(lexer.get_context(">>> foo.bar.baz"),
[ "foo", "bar", "baz" ])
# Test spacing in name.
self.assertEquals(lexer.get_context("foo.bar. baz"), [ "baz" ])
# Test parenthesis.
self.assertEquals(lexer.get_context("foo("), [])
def testC(self):
""" Does the CompletionLexer work for C/C++?
"""
lexer = CompletionLexer(CLexer())
self.assertEquals(lexer.get_context("foo.bar"), [ "foo", "bar" ])
self.assertEquals(lexer.get_context("foo->bar"), [ "foo", "bar" ])
lexer = CompletionLexer(CppLexer())
self.assertEquals(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ])
if __name__ == '__main__':
unittest.main()