Status: Accepted
Owner: sean.v....@gmail.com
Labels: Type-Defect Priority-Medium Quantum
New issue 2633 by sean.v....@gmail.com: Can't print Add of hilbert spaces
http://code.google.com/p/sympy/issues/detail?id=2633
If you print an Add of ComplexSpace's, you get the following error:
In [1]: from sympy.physics.quantum.hilbert import *
In [2]: Add(ComplexSpace(1),ComplexSpace(2))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/sean/<ipython-input-29-96328db77519> in <module>()
----> 1 Add(ComplexSpace(1),ComplexSpace(2))
/home/sean/ipython-dev/IPython/core/displayhook.pyc in __call__(self,
result)
300 self.start_displayhook()
301 self.write_output_prompt()
--> 302 format_dict = self.compute_format_data(result)
303 self.write_format_data(format_dict)
304 self.update_user_ns(result)
/home/sean/ipython-dev/IPython/core/displayhook.pyc in
compute_format_data(self, result)
213 MIME type representation of the object.
214 """
--> 215 return self.shell.display_formatter.format(result)
216
217 def write_format_data(self, format_dict):
/home/sean/ipython-dev/IPython/core/formatters.pyc in format(self, obj,
include, exclude)
120 continue
121 try:
--> 122 data = formatter(obj)
123 except:
124 # FIXME: log the exception
/home/sean/ipython-dev/IPython/core/formatters.pyc in __call__(self, obj)
441 type_pprinters=self.type_printers,
442 deferred_pprinters=self.deferred_printers)
--> 443 printer.pretty(obj)
444 printer.flush()
445 return stream.getvalue()
/home/sean/ipython-dev/IPython/lib/pretty.pyc in pretty(self, obj)
341 for cls in _get_mro(obj_class):
342 if cls in self.type_pprinters:
--> 343 return self.type_pprinters[cls](obj, self,
cycle)
344 else:
345 printer = self._in_deferred_types(cls)
/home/sean/ipython-dev/IPython/extensions/sympyprinting.pyc in
print_basic_unicode(o, p, cycle)
33 if cycle:
34 return p.text('Basic(...)')
---> 35 out = pretty(o, use_unicode=True)
36 if '\n' in out:
37 p.text(u'\n')
/home/sean/sympy/sympy/printing/pretty/pretty.pyc in pretty(expr,
**settings)
1185
1186 try:
-> 1187 return pp.doprint(expr)
1188 finally:
1189 pretty_use_unicode(uflag)
/home/sean/sympy/sympy/printing/pretty/pretty.pyc in doprint(self, expr)
38
39 def doprint(self, expr):
---> 40 return self._print(expr).render(**self._settings)
41
42 # empty op so _print(stringPict) returns the same
/home/sean/sympy/sympy/printing/printer.pyc in _print(self, expr, *args)
246 printmethod = '_print_' + cls.__name__
247 if hasattr(self, printmethod):
--> 248 return getattr(self, printmethod)(expr, *args)
249
250 # Unknown object, fall back to the emptyPrinter.
/home/sean/sympy/sympy/printing/pretty/pretty.pyc in _print_Add(self, expr,
order)
802
803 def _print_Add(self, expr, order=None):
--> 804 terms = self._as_ordered_terms(expr, order=order)
805 pforms, indices = [], []
806
/home/sean/sympy/sympy/printing/printer.pyc in _as_ordered_terms(self,
expr, order)
260 return sorted(Add.make_args(expr),
key=cmp_to_key(Basic._compare_pretty))
261 else:
--> 262 return expr.as_ordered_terms(order=order)
/home/sean/sympy/sympy/core/expr.pyc in as_ordered_terms(self, order, data)
352 """
353 key, reverse = self._parse_order(order)
--> 354 terms, gens = self.as_terms()
355
356 if not any(term.is_Order for term, _ in terms):
/home/sean/sympy/sympy/core/expr.pyc in as_terms(self)
382
383 for term in Add.make_args(self):
--> 384 coeff, _term = term.as_coeff_Mul()
385
386 coeff = complex(coeff)
AttributeError: 'ComplexSpace' object has no attribute 'as_coeff_Mul'
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.