Status: Accepted
Owner: ----
Labels: Type-Defect Priority-Medium Printing

New issue 3035 by asmeu...@gmail.com: TypeError: unsupported operand type(s) for >>: 'mpz' and 'mpf' with the printer
http://code.google.com/p/sympy/issues/detail?id=3035

Everything is just a regular Symbol (no assumptions).

In [200]: lamda*x*Integral(phi(t)*pi*sin(pi*t), (t, 0, 1))
Out[200]:
    1
    ⌠
λ⋅x⋅⎮ π⋅φ(t)⋅sin(π⋅t) dt
    ⌡
    0

In [201]: lamda*x**2*Integral(phi(t)*2*pi*sin(2*pi*t), (t, 0, 1))
Out[201]:
     1
   2 ⌠
λ⋅x ⋅⎮ 2⋅π⋅φ(t)⋅sin(2⋅π⋅t) dt
     ⌡
     0

In [202]: lamda*x*Integral(phi(t)*pi*sin(pi*t), (t, 0, 1)) + lamda*x**2*Integral(phi(t)*2*pi*sin(2*pi*t), (t, 0, 1)) Out[202]: ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Users/aaronmeurer/Documents/Python/sympy/sympy/<ipython-input-202-f879c6e99f81> in <module>() ----> 1 lamda*x*Integral(phi(t)*pi*sin(pi*t), (t, 0, 1)) + lamda*x**2*Integral(phi(t)*2*pi*sin(2*pi*t), (t, 0, 1))

/Users/aaronmeurer/Documents/ipython/IPython/core/displayhook.pyc in __call__(self, result)

/Users/aaronmeurer/Documents/ipython/IPython/core/displayhook.pyc in compute_format_data(self, result)

/Users/aaronmeurer/Documents/ipython/IPython/core/formatters.pyc in format(self, obj, include, exclude)

/Users/aaronmeurer/Documents/ipython/IPython/core/formatters.pyc in __call__(self, obj)

/Users/aaronmeurer/Documents/ipython/IPython/lib/pretty.pyc in pretty(self, obj)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/interactive/printing.pyc in _pretty_print(arg, p, cycle)
     25     def _pretty_print(arg, p, cycle):
     26         """caller for pretty, for use in IPython 0.11"""
---> 27         p.text(stringify_func(arg))
     28
     29     def _result_display(self, arg):

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in pretty(expr, **settings)
   1396     uflag = pretty_use_unicode(use_unicode)
   1397
-> 1398     try:
   1399         return pp.doprint(expr)
   1400     finally:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in doprint(self, expr)
     40             return pretty_use_unicode()
     41
---> 42     def doprint(self, expr):
     43         return self._print(expr).render(**self._settings)
     44

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/printer.pyc in _print(self, expr, *args)
    252                 printmethod = '_print_' + cls.__name__
    253                 if hasattr(self, printmethod):
--> 254                     return getattr(self, printmethod)(expr, *args)
    255
    256             # Unknown object, fall back to the emptyPrinter.


/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.pyc in _print_Add(self, expr, order)
    949         if self.order == 'none':
    950             terms = list(expr.args)
--> 951         else:
    952             terms = self._as_ordered_terms(expr, order=order)
    953         pforms, indices = [], []

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/printer.pyc in _as_ordered_terms(self, expr, order) 266 return sorted(Add.make_args(expr), key=cmp_to_key(Basic._compare_pretty))
    267         else:
--> 268             return expr.as_ordered_terms(order=order)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.pyc in as_ordered_terms(self, order, data)
    471         """
    472         key, reverse = self._parse_order(order)
--> 473         terms, gens = self.as_terms()
    474
    475         if not any(term.is_Order for term, _ in terms):

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.pyc in as_terms(self)
    510                     if factor.is_number:
    511                         try:
--> 512                             coeff *= complex(factor)
    513                         except ValueError:
    514                             pass

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.pyc in __complex__(self)
    162
    163     def __complex__(self):
--> 164         result = self.evalf()
    165         re, im = result.as_real_imag()
    166         return complex(float(re), float(im))

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(self, n, subs, maxn, chop, strict, quad, verbose)
   1053             options['subs'] = subs
   1054         if quad is not None:
-> 1055             options['quad'] = quad
   1056         try:
   1057             result = evalf(self, prec+4, options)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(x, prec, options)
    970 def evalf(x, prec, options):
    971     from sympy import re as re_, im as im_
--> 972     try:
    973         rf = evalf_table[x.func]
    974         r = rf(x, prec, options)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf_integral(expr, prec, options)
    756     workprec = prec
    757     i = 0
--> 758     maxprec = options.get('maxprec', INF)
    759     while 1:
    760         result = do_integral(expr, workprec, options)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in do_integral(expr, prec, options)
    721             result = quadosc(f, [xlow, xhigh], period=period)
    722             # XXX: quadosc does not do error detection yet

--> 723             quadrature_error = MINUS_INF
    724         else:
725 result, quadrature_error = quadts(f, [xlow, xhigh], error=1)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/calculus/quadrature.pyc in quadts(ctx, *args, **kwargs)
    784         """
    785         kwargs['method'] = 'tanh-sinh'
--> 786         return ctx.quad(*args, **kwargs)
    787
    788     def quadgl(ctx, *args, **kwargs):

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/calculus/quadrature.pyc in quad(ctx, f, *points, **kwargs)
    741             ctx.prec += 20
    742             if dim == 1:
--> 743 v, err = rule.summation(f, points[0], prec, epsilon, m, verbose)
    744             elif dim == 2:
    745                 v, err = rule.summation(lambda x: \

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/calculus/quadrature.pyc in summation(self, f, points, prec, epsilon, max_degree, verbose) 230 print("Integrating from %s to %s (degree %s of %s)" % \ 231 (ctx.nstr(a), ctx.nstr(b), degree, max_degree)) --> 232 results.append(self.sum_next(f, nodes, degree, prec, results, verbose))
    233                 if degree > 1:
234 err = self.estimate_error(results, prec, epsilon)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/calculus/quadrature.pyc in sum_next(self, f, nodes, degree, prec, previous, verbose)
    302         else:
    303             S = self.ctx.zero
--> 304         S += self.ctx.fdot((w,f(x)) for (x,w) in nodes)
    305         return h*S
    306

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/ctx_mp_python.pyc in fdot(ctx, A, B, conjugate)
    923         hasattr_ = hasattr
    924         types = (ctx.mpf, ctx.mpc)
--> 925         for a, b in A:
    926             if type(a) not in types: a = ctx.convert(a)
    927             if type(b) not in types: b = ctx.convert(b)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/calculus/quadrature.pyc in <genexpr>((x, w))
    302         else:
    303             S = self.ctx.zero
--> 304         S += self.ctx.fdot((w,f(x)) for (x,w) in nodes)
    305         return h*S
    306

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in f(t)
    694         max_real_term = [MINUS_INF]
    695         max_imag_term = [MINUS_INF]
--> 696
    697         def f(t):
698 re, im, re_acc, im_acc = evalf(func, mp.prec, {'subs':{x:t}})

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(x, prec, options)
    970 def evalf(x, prec, options):
    971     from sympy import re as re_, im as im_
--> 972     try:
    973         rf = evalf_table[x.func]
    974         r = rf(x, prec, options)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf_mul(v, prec, options)
    367     # i**direction

    368     for arg in args:
--> 369         re, im, re_acc, im_acc = evalf(arg, prec, options)
    370         if re and im:
    371             complex_factors.append((re, im, re_acc, im_acc))

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(x, prec, options)
    977         try:
    978             # Fall back to ordinary evalf if possible

--> 979             if 'subs' in options:
    980                 x = x.subs(evalf_subs(prec, options['subs']))
    981             re, im = x._eval_evalf(prec).as_real_imag()

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/function.pyc in _eval_evalf(self, prec)
    285             nargs = cls.nargs
    286
--> 287             i = 0 if nargs is None else 10000
    288
    289         return 4, i, name

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/ctx_mp_python.pyc in __call__(self, prec, dps, rounding)
    344         if not rounding: rounding = rounding2
    345         if dps: prec = dps_to_prec(dps)
--> 346         return self.context.make_mpf(self.func(prec, rounding))
    347
    348     @property

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/libmp/libelefun.pyc in f(prec, rnd)
    114     def f(prec, rnd=round_fast):
    115         wp = prec + 20
--> 116         v = fixed(wp)
    117         if rnd in (round_up, round_ceiling):
    118             v += 1

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/libmp/libelefun.pyc in g(prec, **kwargs)
     95         memo_prec = f.memo_prec
     96         if prec <= memo_prec:
---> 97             return f.memo_val >> (memo_prec-prec)
     98         newprec = int(prec*1.05+10)
     99         f.memo_val = f(newprec, **kwargs)

TypeError: unsupported operand type(s) for >>: 'mpz' and 'mpf'

--
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.

Reply via email to