#13246: Automatic exclusion of non-domain points in things like arcsec
-----------------------------------------+--------------------------
       Reporter:  kcrisman               |        Owner:  jason, was
           Type:  defect                 |       Status:  needs_work
       Priority:  major                  |    Milestone:  sage-6.3
      Component:  graphics               |   Resolution:
       Keywords:                         |    Merged in:
        Authors:  Punarbasu Purkayastha  |    Reviewers:
Report Upstream:  N/A                    |  Work issues:
         Branch:                         |       Commit:
   Dependencies:                         |     Stopgaps:
-----------------------------------------+--------------------------
Changes (by ppurka):

 * cc: vbraun (added)


Comment:

 What do you make of this? Bug in cython? cc: vbraun

 {{{
 sage: from sage.plot.misc import setup_for_eval_on_grid
 sage: f, d = setup_for_eval_on_grid(arcsec, [(-2, 2)])
 sage: f(-0.992725195401)
 ---------------------------------------------------------------------------
 AttributeError                            Traceback (most recent call
 last)
 <ipython-input-3-a06f3eb7afeb> in <module>()
 ----> 1 f(-RealNumber('0.992725195401'))

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/ext/interpreters/wrapper_rdf.so in
 sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__
 (sage/ext/interpreters/wrapper_rdf.c:1689)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/symbolic/function.so in
 sage.symbolic.function.BuiltinFunction.__call__
 (sage/symbolic/function.cpp:9088)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/symbolic/expression.so in
 sage.symbolic.expression.Expression.__complex__
 (sage/symbolic/expression.cpp:8174)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/symbolic/expression.so in
 sage.symbolic.expression.Expression._eval_self
 (sage/symbolic/expression.cpp:6973)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/functions/trig.pyc in _evalf_(self, x, parent, algorithm)
     732         if parent is float:
     733             return math.acos(1/x)
 --> 734         return (1/x).arccos()
     735
     736     def _eval_numpy_(self, x):

 AttributeError: 'complex' object has no attribute 'arccos'
 sage:
 Exiting Sage (CPU time 0m0.25s, Wall time 0m12.78s).


 basu@plantain:~/Installations/sage [test-float] $ git diff develop |cat  #
 insert a print statement
 diff --git a/src/sage/symbolic/function.pyx
 b/src/sage/symbolic/function.pyx
 index eed56e6..75c723d 100644
 --- a/src/sage/symbolic/function.pyx
 +++ b/src/sage/symbolic/function.pyx
 @@ -934,6 +934,7 @@ cdef class BuiltinFunction(Function):
              # conversion to the original parent failed
              # we try if it works with the corresponding complex domain
              if org_parent is float:
 +                print "DEBUG: it is float - {}".format(float(res))
                  try:
                      return complex(res)
                  except (TypeError, ValueError):



 basu@plantain:~/Installations/sage [test-float] $ ./sage -b >& /dev/null ;
 ./sage
 ┌────────────────────────────────────────────────────────────────────┐
 │ Sage Version 6.3.beta2, Release Date: 2014-05-24                   │
 │ Type "notebook()" for the browser-based notebook interface.        │
 │ Type "help()" for help.                                            │
 └────────────────────────────────────────────────────────────────────┘
 ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
 ┃ Warning: this is a prerelease version, and it may be unstable.     ┃
 ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
 sage: from sage.plot.misc import setup_for_eval_on_grid
 sage: f, d = setup_for_eval_on_grid(arcsec, [(-2, 2)])
 sage: f(-0.992725195401)
 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent call
 last)
 <ipython-input-3-a06f3eb7afeb> in <module>()
 ----> 1 f(-RealNumber('0.992725195401'))

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/ext/interpreters/wrapper_rdf.so in
 sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__
 (sage/ext/interpreters/wrapper_rdf.c:1689)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/symbolic/function.so in
 sage.symbolic.function.BuiltinFunction.__call__
 (sage/symbolic/function.cpp:9099)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/symbolic/expression.so in
 sage.symbolic.expression.Expression.__float__
 (sage/symbolic/expression.cpp:8022)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/symbolic/expression.so in
 sage.symbolic.expression.Expression._eval_self
 (sage/symbolic/expression.cpp:6973)()

 /home/basu/Installations/sage/local/lib/python2.7/site-
 packages/sage/functions/trig.pyc in _evalf_(self, x, parent, algorithm)
     731         """
     732         if parent is float:
 --> 733             return math.acos(1/x)
     734         return (1/x).arccos()
     735

 ValueError: math domain error
 sage:
 }}}
 The error changes to `ValueError` from `AttributeError`. How can a print
 statement change the call sequence?

--
Ticket URL: <http://trac.sagemath.org/ticket/13246#comment:28>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to