Opened 11 years ago

Closed 11 years ago

#7810 closed defect (duplicate)

bug in fast_callable (reducing empty sequence)

Reported by: jason Owned by: AlexGhitza
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: basic arithmetic Keywords:
Cc: cwitty, burcin Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

sage: var('x,y')
sage: fast_float(-1/x-1/y+1/(x*y),x,y)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/grout/.sage/temp/tiny/2056/_home_grout__sage_init_sage_0.py in <module>()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_eval.so in sage.ext.fast_eval.fast_float (sage/ext/fast_eval.c:8434)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.fast_callable (sage/ext/fast_callable.c:3134)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:24715)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in fast_callable(ex, etb)
   1353 
   1354     """
-> 1355     return FastCallableConverter(ex, etb)()
   1356 
   1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
    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:
    216             return self.relation(ex, operator)

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in <lambda>(x, y)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:4986)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4313)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:24715)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in fast_callable(ex, etb)
   1353 
   1354     """
-> 1355     return FastCallableConverter(ex, etb)()
   1356 
   1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc 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:

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in <lambda>(x, y)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:4986)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4313)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in _fast_callable_(self, etb)
    119             [('load_arg', 0), ('load_arg', 1), 'div', 'return']
    120         """
--> 121         return fast_callable(self, etb)
    122 
    123     def _fast_float_(self, *vars):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in fast_callable(ex, etb)
   1353 
   1354     """
-> 1355     return FastCallableConverter(ex, etb)()
   1356 
   1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc 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:

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

TypeError: reduce() of empty sequence with no initial value
sage: fast_callable(-1/x-1/y+1/(x*y),vars=[x,y])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/grout/.sage/temp/tiny/2056/_home_grout__sage_init_sage_0.py in <module>()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.fast_callable (sage/ext/fast_callable.c:3134)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:24715)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in fast_callable(ex, etb)
   1353 
   1354     """
-> 1355     return FastCallableConverter(ex, etb)()
   1356 
   1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
    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:
    216             return self.relation(ex, operator)

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in <lambda>(x, y)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:4986)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4313)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:24715)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in fast_callable(ex, etb)
   1353 
   1354     """
-> 1355     return FastCallableConverter(ex, etb)()
   1356 
   1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc 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:

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in <lambda>(x, y)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:4986)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4313)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in _fast_callable_(self, etb)
    119             [('load_arg', 0), ('load_arg', 1), 'div', 'return']
    120         """
--> 121         return fast_callable(self, etb)
    122 
    123     def _fast_float_(self, *vars):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in fast_callable(ex, etb)
   1353 
   1354     """
-> 1355     return FastCallableConverter(ex, etb)()
   1356 
   1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc 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:

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
   1293         elif operator is _operator.neg:
   1294             return self.etb.call(operator, operands[0])
-> 1295         return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
   1296 
   1297     def symbol(self, ex):

TypeError: reduce() of empty sequence with no initial value

Change History (4)

comment:1 Changed 11 years ago by burcin

  • Cc burcin added

comment:2 Changed 11 years ago by burcin

This works for me after applying the patch at #8056. Since the patch is attached there, I suggest we close this as a duplicate.

sage: var('x,y')
(x, y)
sage: fast_float(-1/x-1/y+1/(x*y),x,y)
<sage.ext.interpreters.wrapper_rdf.Wrapper_rdf object at 0x7fc3b89ba248>

comment:3 Changed 11 years ago by jason

This works for me in 4.3.3 too. This ticket should be closed.

comment:4 Changed 11 years ago by mvngu

  • Milestone changed from sage-4.3.4 to sage-duplicate/invalid/wontfix
  • Resolution set to duplicate
  • Status changed from new to closed

Close as a duplicate of #8056.

Note: See TracTickets for help on using tickets.