The try/except block was again testing several lines at once and thus was hiding problems. Things were made explicit by this patch.
Signed-off-by: Ondrej Certik <ond...@certik.cz> --- sympy/core/basic.py | 3 +++ sympy/core/evalf.py | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sympy/core/basic.py b/sympy/core/basic.py index 1cd9c2a..2e7a1e0 100644 --- a/sympy/core/basic.py +++ b/sympy/core/basic.py @@ -1966,6 +1966,9 @@ def _evalf(self, prec): return r def _eval_evalf(self, prec): + """ + Returns evaluated self, or None if it can't be evaluated. + """ return def _seq_eval_evalf(self, prec): diff --git a/sympy/core/evalf.py b/sympy/core/evalf.py index 6ce9642..a32d9b8 100644 --- a/sympy/core/evalf.py +++ b/sympy/core/evalf.py @@ -885,7 +885,7 @@ def evalf_sum(expr, prec, options): def evalf_symbol(x, prec, options): if not 'subs' in options: - raise NotImplementedError() + raise NotImplementedError val = options['subs'][x] if isinstance(val, mpf): if not val: @@ -951,12 +951,16 @@ def evalf(x, prec, options): if rf is not None: r = rf(x, prec, options) else: - try: - # Fall back to ordinary evalf if possible - if 'subs' in options: - x = x.subs(options['subs']) - r = x._eval_evalf(prec)._mpf_, None, prec, None - except AttributeError: + # Fall back to ordinary evalf if possible + if 'subs' in options: + x = x.subs(options['subs']) + if hasattr(x, '_eval_evalf'): + r = x._eval_evalf(prec) + if r is None: + raise NotImplementedError + else: + r = r._mpf_, None, prec, None + else: raise NotImplementedError if options.get("verbose"): print "### input", x -- 1.6.2.1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---