There's a "return" missing: $ git diff diff --git a/sympy/functions/elementary/trigonometric.py b/sympy/functions/elementary/trigonometric.py index 635e7f2..b7a0ad1 100644 --- a/sympy/functions/elementary/trigonometric.py +++ b/sympy/functions/elementary/trigonometric.py @@ -3070,4 +3070,4 @@ def fdiff(self, argindex): def _eval_evalf(self, prec): y, x = self.args if x.is_extended_real and y.is_extended_real: - super(atan2, self)._eval_evalf(prec) + return super(atan2, self)._eval_evalf(prec)
Also it checks if the args are real so it looks like you might need to declare your variables a and y with real=True. If you do that then the result is caculated as: 0.785398163397448 Can you open an issue on Github for this? On Tue, 20 Aug 2019 at 15:34, Ville Bergholm <ville.bergh...@iki.fi> wrote: > > I've been trying to use sympy.Symbol to implement a system where the > numerical value of a symbolic quantity is only fixed when it is evaluated > using evalf(). > To accomplish this I've redefined _eval_evalf() to return the aforementioned > value (a fixed 5.0 in the toy example below). > > This works fine with basic algebraic operations and most SymPy functions. > However, for some reason atan2 seems to behave differently and _eval_evalf is > never called. > Is this a bug, or have I misunderstood the purpose of _eval_evalf? > > > import sympy > import sympy.functions as syf > > class A(sympy.Symbol): > def _eval_evalf(self, prec): > print('*') > return sympy.Float(5.0) > > x = A('X') > y = A('Y') > print('polynomial:') > print((2*x-4+y).evalf()) # works fine > print('atan:') > print(syf.atan(y / x).evalf()) # works fine > print('beta:') > print(syf.beta(y, x).evalf()) # works fine > print('atan2:') > print(syf.atan2(y, x).evalf()) # prints "atan2(Y, X)", does not call > A._eval_evalf > > -- > 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 sympy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/4480befb-c8d3-48f1-a1be-b5e8bd55a0be%40googlegroups.com. -- 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 sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxSD2zW1%3DQ_H4%2BJX%3D3%2BTRRd%3DeKObMqW-udsRY-GSZnOX4A%40mail.gmail.com.