Opened 11 years ago

Closed 11 years ago

# bug in fast_callable (reducing empty sequence)

Reported by: Owned by: jason AlexGhitza major sage-duplicate/invalid/wontfix basic arithmetic cwitty, burcin N/A

### 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>()

1353
1354     """
-> 1355     return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

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)

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):

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):

1353
1354     """
-> 1355     return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

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:

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):

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):

120         """
--> 121         return fast_callable(self, etb)
122
123     def _fast_float_(self, *vars):

1353
1354     """
-> 1355     return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

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:

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>()

1353
1354     """
-> 1355     return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

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)

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):

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):

1353
1354     """
-> 1355     return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

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:

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):

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):

120         """
--> 121         return fast_callable(self, etb)
122
123     def _fast_float_(self, *vars):

1353
1354     """
-> 1355     return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

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:

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
```

### 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.