when I start ipython with "ipython --profile=sympy" I get

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
Type "copyright", "credits" or "license" for more information.

IPython 0.13.dev -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

IPython profile: sympy
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/brombo/GITHUB/sympy/sympy/galgebra/<ipython-input-1-09a68e4620ec> in <module>()
      4 x, y, z, t = symbols('x y z t')
      5 k, m, n = symbols('k m n', integer=True)
----> 6 f, g, h = symbols('f g h', cls=Function)

/usr/local/lib/python2.7/dist-packages/sympy-0.6.7_git-py2.7.egg/sympy/core/symbol.pyc in symbols(*names, **kwargs)
    234             if not t:
    235                 continue
--> 236             sym = Symbol(t, **kwargs)
    237             res.append(sym)
    238         res = tuple(res)

TypeError: __new__() got multiple values for keyword argument 'cls'

In [1]:

then everything works ok. If I start ipython with "ipython notebook --profile=sympy" everything works OK from the start. Note that I have modified sympyprinting.py (attached) so that ipython printing works with the geometric algebra module.

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

"""
A print function that pretty prints sympy Basic objects.

:moduleauthor: Brian Granger

Usage
=====

Once the extension is loaded, Sympy Basic objects are automatically
pretty-printed.

"""
#-----------------------------------------------------------------------------
#  Copyright (C) 2008-2011  The IPython Development Team
#
#  Distributed under the terms of the BSD License.  The full license is in
#  the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

from IPython.lib.latextools import latex_to_png
from IPython.testing import decorators as dec
# use @dec.skipif_not_sympy to skip tests requiring sympy

try:
    #from sympy import pretty, latex
    from sympy import pretty
    from sympy.galgebra.latex_ex import LaTeX
    from sympy.galgebra.GA import MV
except ImportError:
    pass


#-----------------------------------------------------------------------------
# Definitions of magic functions for use with IPython
#-----------------------------------------------------------------------------

def print_basic_unicode(o, p, cycle):
    """A function to pretty print sympy Basic objects."""

    if cycle:
        return p.text('Basic(...)')
    if isinstance(o,MV):
        out = MV.str_rep(o)
    else:
        out = pretty(o, use_unicode=True)
    if '\n' in out:
        p.text(u'\n')
    p.text(out)


def print_png(o):
    """A function to display sympy expression using LaTex -> PNG."""
    #s = latex(o, mode='inline')
    # mathtext does not understand certain latex flags, so we try to replace
    # them with suitable subs.
    s = LaTeX(o,itex=True)
    s = s.replace('\\operatorname','')
    s = s.replace('\\overline', '\\bar')
    png = latex_to_png(s)
    return png

newcommands =  '$\\newcommand{\\bfrac}[2]{\\displaystyle\\frac{#1}{#2}}$\n'+\
               '$\\newcommand{\\lp}{\\left (}$\n'+\
               '$\\newcommand{\\rp}{\\right )}$\n'+\
               '$\\newcommand{\\half}{\\frac{1}{2}}$\n'+\
               '$\\newcommand{\\llt}{\\left <}$\n'+\
               '$\\newcommand{\\rgt}{\\right >}$\n'+\
               '$\\newcommand{\\abs}[1]{\\left |{#1}\\right | }$\n'+\
               '$\\newcommand{\\pdiff}[2]{\\bfrac{\\partial {#1}}{\\partial {#2}}}$\n'+\
               '$\\newcommand{\\lbrc}{\\left \\{}$\n'+\
               '$\\newcommand{\\rbrc}{\\right \\}}$\n'+\
               '$\\newcommand{\\W}{\\wedge}$\n'+\
               "$\\newcommand{\\prm}[1]{{#1}'}$\n"+\
               '$\\newcommand{\\ddt}[1]{\\bfrac{d{#1}}{dt}}$\n'+\
               '$\\newcommand{\\R}{\\dagger}$\n'+\
               '$\\newcommand{\\bm}{\\boldsymbol}$\n'

_first_pass = True

def print_latex(o):
    global _first_pass,newcommands
    """A function to generate the latex representation of sympy expressions."""
    #s = latex(o, mode='equation', itex=True)
    s = LaTeX(o,itex=True)
    #s = s.replace('\\dag','\\dagger')
    if _first_pass:
        _first_pass = False
        s = newcommands+s
    return s

_loaded = False

def load_ipython_extension(ip):
    """Load the extension in IPython."""
    global _loaded
    if not _loaded:
        plaintext_formatter = ip.display_formatter.formatters['text/plain']

        for cls in (object, tuple, list, set, frozenset, dict, str):
            plaintext_formatter.for_type(cls, print_basic_unicode)

        plaintext_formatter.for_type_by_name(
            'sympy.core.basic', 'Basic', print_basic_unicode
        )
        plaintext_formatter.for_type_by_name(
            'sympy.matrices.matrices', 'Matrix', print_basic_unicode
        )
        plaintext_formatter.for_type_by_name(
            'sympy.galgebra.GA', 'MV', print_basic_unicode
        )
        png_formatter = ip.display_formatter.formatters['image/png']

        png_formatter.for_type_by_name(
            'sympy.core.basic', 'Basic', print_png
        )

        latex_formatter = ip.display_formatter.formatters['text/latex']
        latex_formatter.for_type_by_name(
            'sympy.core.basic', 'Basic', print_latex
        )
        latex_formatter.for_type_by_name(
            'sympy.matrices.matrices', 'Matrix', print_latex
        )
        latex_formatter.for_type_by_name(
            'sympy.galgebra.GA', 'MV', print_latex
        )
        _loaded = True

Reply via email to