We should do an audit of this. Check for all instances of git grep '^
*if.*[<>]' to see make sure the comparison cannot be symbolic.

Aaron Meurer

On Sun, Mar 9, 2014 at 5:38 PM, Aaron Meurer <[email protected]> wrote:
> It's a bug. The code in trigonometric.py should be using (self.args[0]
> + 1).is_nonnegative and (self.args[0] - 1).is_nonpositive.
>
> Aaron Meurer
>
> On Fri, Mar 7, 2014 at 1:43 PM, Manuel Schleiffelder
> <[email protected]> wrote:
>> hello everyone,
>>
>> i am working on plots in the complex-plane and got stuck trying to
>> sutbstitue values to the symbols of a certain class of equations. the wired
>> thing is, that i only get the "TypeError" the first time i substitute(In
>> [3]:). second try it works(In [4]:) like a charm until i alter the equation
>> or start over again.
>>
>> i was able to track the error down to a simpler form of nested functions
>> (mathematically senseless, just for demonstration purposes):
>>
>>>>> re(acos(re(x))).subs(x,5)
>>
>> where i can exchange the complex functions arbitrary by another one (re(),
>> im(), Abs(), arg()) and the trigonometric function "acos()" can also be a
>> "asin()" still producing the same error. this also occurs in python 2.7.
>>
>> any idea anybody?  is this a bug?
>>
>> great thanks,
>> manuel
>>
>>
>> Python 3.2.3 (default, Sep 25 2013, 19:36:10)
>> Type "copyright", "credits" or "license" for more information.
>>
>> IPython 0.13.1.rc2 -- 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.
>>
>> In [1]: from sympy import *
>>
>> In [2]: x = symbols('x')
>>
>> In [3]: re(acos(re(x))).subs(x,5)
>> ---------------------------------------------------------------------------
>> TypeError                                 Traceback (most recent call last)
>> <ipython-input-3-515558ca2309> in <module>()
>> ----> 1 re(acos(re(x))).subs(x,5)
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/core/cache.py in wrapper(*args,
>> **kw_args)
>>      91         except (KeyError, TypeError):
>>      92             pass
>> ---> 93         r = func(*args, **kw_args)
>>      94         try:
>>      95             func_cache_it_cache[k] = r
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/core/function.py in
>> __new__(cls, *args, **options)
>>     366
>>     367         evaluate = options.get('evaluate', True)
>> --> 368         result = super(Function, cls).__new__(cls, *args, **options)
>>     369         if not evaluate or not isinstance(result, cls):
>>     370             return result
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/core/cache.py in wrapper(*args,
>> **kw_args)
>>      91         except (KeyError, TypeError):
>>      92             pass
>> ---> 93         r = func(*args, **kw_args)
>>      94         try:
>>      95             func_cache_it_cache[k] = r
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/core/function.py in
>> __new__(cls, *args, **options)
>>     196
>>     197         if evaluate:
>> --> 198             evaluated = cls.eval(*args)
>>     199             if evaluated is not None:
>>     200                 return evaluated
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/functions/elementary/complexes.py
>> in eval(cls, arg)
>>      50         if arg is S.NaN:
>>      51             return S.NaN
>> ---> 52         elif arg.is_real:
>>      53             return arg
>>      54         elif arg.is_imaginary:
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/core/assumptions.py in
>> getit(self)
>>     142             if self._assumptions is self.default_assumptions:
>>     143                 self._assumptions = self.default_assumptions.copy()
>> --> 144             return _ask(fact, self)
>>     145
>>     146     getit.func_name = as_property(fact)
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/core/assumptions.py in
>> _ask(fact, obj)
>>     185         pass
>>     186     else:
>> --> 187         a = evaluate(obj)
>>     188         if a is not None:
>>     189             assumptions.deduce_all_facts(((fact, a),))
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/functions/elementary/trigonometric.py
>> in _eval_is_real(self)
>>    1546
>>    1547     def _eval_is_real(self):
>> -> 1548         return self.args[0].is_real and (self.args[0] >= -1 and
>> self.args[0] <= 1)
>>    1549
>>    1550     def _eval_rewrite_as_log(self, x):
>>
>> /usr/local/lib/python3.2/dist-packages/sympy/core/relational.py in
>> __nonzero__(self)
>>     109
>>     110     def __nonzero__(self):
>> --> 111         raise TypeError("symbolic boolean expression has no truth
>> value.")
>>     112
>>     113     __bool__ = __nonzero__
>>
>> TypeError: symbolic boolean expression has no truth value.
>>
>> In [4]: re(acos(re(x))).subs(x,5)
>> Out[4]: re(acos(5))
>>
>> In [5]:
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/2c570431-8d88-4db0-8a59-b954dba91c90%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6LONEAt2iaKk5dxUV3bzOhy36AVveQB_qHqppC-QG909A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to