Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium Solvers

New issue 3663 by [email protected]: TypeError: unsupported operand type(s) for /: 'mpz' and 'float'
http://code.google.com/p/sympy/issues/detail?id=3663

In [2]: solve(x**3 + x**2*y - 2*x - 3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-e3476d92f347> in <module>()
----> 1 solve (x **Integer (3 )+x **Integer (2 )*y -Integer (2 )*x -Integer (3 ))

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/solvers/solvers.pyc in solve(f, *symbols, **flags) 822 ###########################################################################
    823     if bare_f:
--> 824         solution = _solve(f[0], *symbols, **flags)
    825     else:
    826         solution = _solve_system(f, symbols, **flags)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/solvers/solvers.pyc in _solve(f, *symbols, **flags)
   1044         for s in failed:
   1045             try:
-> 1046                 soln = _solve(f, s, **flags)
   1047                 for sol in soln:
1048 if got_s and any([ss in sol.free_symbols for ss in got_s]):

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/solvers/solvers.pyc in _solve(f, *symbols, **flags)
   1285         # keep only results if the check is not False
   1286         result = [r for r in result if
-> 1287 checksol(f_num, {symbol: r}, **flags) is not False]
   1288     return result
   1289

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/solvers/solvers.pyc in checksol(f, symbol, sol, **flags) 194 # there are free symbols -- simple expansion might work
    195                 _, val = val.as_content_primitive()
--> 196                 val = expand_mul(expand_multinomial(val))
    197         elif attempt == 2:
    198             if flags.get('minimal', False):

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/function.pyc in expand_multinomial(expr, deep)
   1819     """
1820 return sympify(expr).expand(deep=deep, mul=False, power_exp=False,
-> 1821     power_base=False, basic=False, multinomial=True, log=False)
   1822
   1823

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     90         except KeyError:
     91             pass
---> 92         func_cache_it_cache[k] = r = func(*args, **kw_args)
     93         return r
     94     return wrapper

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.pyc in expand(self, deep, modulus, power_base, power_exp, mul, log, multinomial, basic, **hints)
   2736             use_hint = hints[hint]
   2737             if use_hint:
-> 2738 expr, hit = Expr._expand_hint(expr, hint, deep=deep, **hints)
   2739
   2740         if modulus is not None:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.pyc in _expand_hint(expr, hint, deep, **hints)
   2672             sargs = []
   2673             for arg in expr.args:
-> 2674                 arg, arghit = Expr._expand_hint(arg, hint, **hints)
   2675                 hit |= arghit
   2676                 sargs.append(arg)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.pyc in _expand_hint(expr, hint, deep, **hints)
   2672             sargs = []
   2673             for arg in expr.args:
-> 2674                 arg, arghit = Expr._expand_hint(arg, hint, **hints)
   2675                 hit |= arghit
   2676                 sargs.append(arg)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.pyc in _expand_hint(expr, hint, deep, **hints)
   2680
   2681         if hasattr(expr, '_eval_expand_' + hint):
-> 2682             newexpr = getattr(expr, '_eval_expand_' + hint)(**hints)
   2683             if newexpr != expr:
   2684                 return (newexpr, True)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/power.pyc in _eval_expand_multinomial(self, **hints)
    597
    598                 from sympy.polys.polyutils import basic_from_dict
--> 599                 result = basic_from_dict(expansion_dict, *p)
    600                 return result
    601             else:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/polys/polyutils.pyc in expr_from_dict(rep, *gens)
    340         for g, m in zip(gens, monom):
    341             if m:
--> 342                 term.append(Pow(g, m))
    343
    344         result.append(Mul(*term))

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     90         except KeyError:
     91             pass
---> 92         func_cache_it_cache[k] = r = func(*args, **kw_args)
     93         return r
     94     return wrapper

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/power.pyc in __new__(cls, b, e, evaluate)
    100                 return S.NaN
    101             else:
--> 102                 obj = b._eval_power(e)
    103                 if obj is not None:
    104                     return obj

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/mul.pyc in _eval_power(b, e)
    524
    525         if e.is_Integer:
--> 526 return Mul(*[Pow(b, e, evaluate=False) for b in cargs]) * \
    527                 Pow(Mul._from_args(nc), e, evaluate=False)
    528

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     90         except KeyError:
     91             pass
---> 92         func_cache_it_cache[k] = r = func(*args, **kw_args)
     93         return r
     94     return wrapper

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/operations.pyc in __new__(cls, *args, **options)
     36             return args[0]
     37
---> 38         c_part, nc_part, order_symbols = cls.flatten(args)
     39         is_commutative = not nc_part
     40         obj = cls._from_args(c_part + nc_part, is_commutative)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/mul.pyc in flatten(cls, seq)
    366                     c_part.append(b)
    367             elif e is not S.Zero:
--> 368                 c_part.append(Pow(b, e))
    369
    370         #  x    x     x

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     90         except KeyError:
     91             pass
---> 92         func_cache_it_cache[k] = r = func(*args, **kw_args)
     93         return r
     94     return wrapper

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/power.pyc in __new__(cls, b, e, evaluate)
    100                 return S.NaN
    101             else:
--> 102                 obj = b._eval_power(e)
    103                 if obj is not None:
    104                     return obj

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/power.pyc in _eval_power(self, other)
    132             smallarg = (abs(e) <= S.Zero)
    133         else:
--> 134             smallarg = (abs(e) <= abs(S.Pi/log(b)))
    135         if (other.is_Rational and other.q == 2 and
    136                 e.is_real is False and smallarg is False):

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/numbers.pyc in __le__(self, other)
   1658         elif isinstance(other, Integer):
   1659             return (self.p <= other.p)
-> 1660         return Rational.__le__(self, other)
   1661
   1662     def __hash__(self):

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/numbers.pyc in __le__(self, other)
   1359             return other.__gt__(self)
1360 if other.is_real and other.is_number and not isinstance(other, Rational):
-> 1361             other = other.evalf()
   1362         if isinstance(other, Number):
   1363             if other is S.NaN:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(self, n, subs, maxn, chop, strict, quad, verbose)
   1279             options['quad'] = quad
   1280         try:
-> 1281             result = evalf(self, prec + 4, options)
   1282         except NotImplementedError:
   1283             # Fall back to the ordinary evalf

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(x, prec, options)
   1179     try:
   1180         rf = evalf_table[x.func]
-> 1181         r = rf(x, prec, options)
   1182     except KeyError:
   1183         try:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf_mul(v, prec, options)
    495     special = []
    496     for arg in args:
--> 497         arg = evalf(arg, prec, options)
    498         if arg[0] is None:
    499             continue

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(x, prec, options)
   1179     try:
   1180         rf = evalf_table[x.func]
-> 1181         r = rf(x, prec, options)
   1182     except KeyError:
   1183         try:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf_abs(expr, prec, options)
    224
    225 def evalf_abs(expr, prec, options):
--> 226     return get_abs(expr.args[0], prec, options)
    227
    228

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in get_abs(expr, prec, options)
    198
    199 def get_abs(expr, prec, options):
--> 200     re, im, re_acc, im_acc = evalf(expr, prec + 2, options)
    201     if not re:
    202         re, re_acc, im, im_acc = im, im_acc, re, re_acc

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(x, prec, options)
   1179     try:
   1180         rf = evalf_table[x.func]
-> 1181         r = rf(x, prec, options)
   1182     except KeyError:
   1183         try:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf_pow(v, prec, options) 612 # base must be evaluated with increased precision if p is large
    613         prec += int(math.log(abs(p), 2))
--> 614         re, im, re_acc, im_acc = evalf(base, prec + 5, options)
    615         # Real to integer power
    616         if re and not im:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf(x, prec, options)
   1179     try:
   1180         rf = evalf_table[x.func]
-> 1181         r = rf(x, prec, options)
   1182     except KeyError:
   1183         try:

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/evalf.pyc in evalf_log(expr, prec, options)
    771         re = evalf_log(
772 C.log(C.Abs(arg, evaluate=False), evaluate=False), prec, options)
--> 773         im = mpf_atan2(xim, xre or fzero, prec)
    774         return re[0], im, re[2], prec
    775

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/libmp/libelefun.pyc in mpf_atan2(y, x, prec, rnd)
    904             return fzero
    905         return mpf_shift(mpf_pi(prec, rnd), -1)
--> 906     tquo = mpf_atan(mpf_div(y, x, prec+4), prec+4)
    907     if xsign:
    908         return mpf_add(mpf_pi(prec+4), tquo, prec, rnd)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/libmp/libelefun.pyc in mpf_atan(x, prec, rnd)
    865         t = -t
    866     if wp < ATAN_TAYLOR_PREC:
--> 867         a = atan_taylor(t, wp)
    868     else:
    869         a = atan_newton(t, wp)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/libmp/libelefun.pyc in atan_taylor(x, prec)
    817 def atan_taylor(x, prec):
    818     n = (x >> (prec-ATAN_TAYLOR_SHIFT))
--> 819     a, atan_a = atan_taylor_get_cached(n, prec)
    820     d = x - a
821 s0 = v = (d << prec) // ((a**2 >> prec) + (a*d >> prec) + (MPZ_ONE << prec))

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/libmp/libelefun.pyc in atan_taylor_get_cached(n, prec)
    811     else:
    812         a = n << (prec2 - ATAN_TAYLOR_SHIFT)
--> 813         atan_a = atan_newton(a, prec2)
    814         atan_taylor_cache[n, prec2] = (a, atan_a)
    815     return (a >> dprec), (atan_a >> dprec)

/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/mpmath/libmp/libelefun.pyc in atan_newton(x, prec)
    784 def atan_newton(x, prec):
    785     if prec >= 100:
--> 786         r = math.atan((x>>(prec-53))/2.0**53)
    787     else:
    788         r = math.atan(x/2.0**prec)

TypeError: unsupported operand type(s) for /: 'mpz' and 'float'



--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

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


Reply via email to