Ticket #8056 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

symbolic expressions involving rational functions with numerator 1 cannot be converted to fast callable

Reported by: burcin Owned by: burcin
Priority: major Milestone: sage-4.3.3
Component: symbolics Keywords:
Cc: schilly, kcrisman Work issues:
Report Upstream: N/A Reviewers: Thomas Hupfer
Authors: Burcin Erocal Merged in: sage-4.3.3.alpha0
Dependencies: Stopgaps:

Description

From the sage-devel list:

 http://groups.google.com/group/sage-devel/t/575627f654d21dd9

sage: t = 1/pi/x
sage: from sage.ext.fast_callable import ExpressionTreeBuilder
sage: etb = ExpressionTreeBuilder(vars=[x])
sage: t._fast_callable_(etb)
<boom>

Attachments

trac_8056-fast_callable.patch Download (1.9 KB) - added by burcin 3 years ago.
trac_8056-fast_callable.take2.patch Download (2.2 KB) - added by burcin 3 years ago.
second try

Change History

Changed 3 years ago by burcin

comment:1 Changed 3 years ago by burcin

  • Status changed from new to needs_review

comment:2 Changed 3 years ago by schilly

I asked the reporter of the bug, and he found yet another problem. I think it's still related:

For me the patch fixes the problem only partially.

things like

var('X'); f(x)=1/pi/x; fast_callable(f)(x)

do now work as expected, but

var('X'); f(x)=1/pi/x; plot(f,2,3)

still fails -- now with a different error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/<ipython console> in <module>()

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-packages/sage/plot/misc.pyc in wrapper(*args,
**kwds)
   241                     kwds[new_name] = kwds[old_name]
   242                     del kwds[old_name]
--> 243             return func(*args, **kwds)
   244
   245         from sage.misc.sageinspect import sage_getsource

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-packages/sage/plot/misc.pyc in wrapper(*args,
**kwds)
   136                 options['__original_opts'] = kwds
   137             options.update(kwds)
--> 138             return func(*args, **options)
   139
   140

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-packages/sage/plot/plot.pyc in plot(funcs,
*args, **kwds)
  2463
  2464     if hasattr(funcs, 'plot'):
-> 2465         G = funcs.plot(*args, **original_opts)
  2466     # if we are using the generic plotting method
  2467     else:

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-packages/sage/symbolic/expression.so in
sage.symbolic.expression.Expression.plot (sage/symbolic/expression.cpp:25582)
()

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-packages/sage/symbolic/expression.so in
sage.symbolic.expression.Expression._plot_fast_callable
(sage/symbolic/expression.cpp:26014)()

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-packages/sage/symbolic/expression.so in
sage.symbolic.expression.Expression._fast_float_
(sage/symbolic/expression.cpp:25025)()

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-
packages/sage/symbolic/expression_conversions.py in fast_float(ex, *vars)
  1199         1.4142135623730951
  1200     """
-> 1201     return FastFloatConverter(ex, *vars)()
  1202
  1203 #################

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-
packages/sage/symbolic/expression_conversions.py in __call__(self, ex)
   211             if getattr(self, 'use_fake_div', False) and operator is
_operator.mul:
   212                 div = self.get_fake_div(ex)
--> 213                 return self.arithmetic(div, div.operator())
   214             return self.arithmetic(ex, operator)
   215         elif operator in relation_operators:

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-
packages/sage/symbolic/expression_conversions.py in arithmetic(self, ex,
operator)
  1150             from sage.functions.all import sqrt
  1151             return sqrt(self(operands[0]))
-> 1152         fops = map(self, operands)
  1153         return reduce(operator, fops)
  1154

/usr/local/sage-mathe/sage-4.3.1-linux-openSUSE_11.1_x86_64-x86_64-
Linux/local/lib/python2.6/site-
packages/sage/symbolic/expression_conversions.py in __call__(self, ex)
   198
   199         try:
--> 200             obj = ex.pyobject()
   201             return self.pyobject(ex, obj)
   202         except TypeError, err:

AttributeError: 'sage.rings.integer.Integer' object has no attribute
'pyobject'

Changed 3 years ago by burcin

second try

comment:3 Changed 3 years ago by burcin

  • Reviewers set to Harald Schilly

Thank you for the review.

attachment:trac_8056-fast_callable.take2.patch Download uses SR.one_element() instead of ZZ(1). This fixes the problems reported in comment:2.

Apply only attachment:trac_8056-fast_callable.take2.patch Download.

Can you take another look?

comment:4 Changed 3 years ago by schilly

  • Status changed from needs_review to positive_review
  • Reviewers changed from Harald Schilly to Thomas Hupfer

thomas hupfer:

looks good, plotting now works for me as expected.

comment:5 Changed 3 years ago by mpatel

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.3.3.alpha0
Note: See TracTickets for help on using tickets.