Skip to content

Commit

Permalink
fix sum *args
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout4 committed Jul 18, 2024
1 parent cdd80f4 commit 32a23d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cpmpy/expressions/python_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def sum(*iterable, **kwargs):
if iterable does not contain CPMpy expressions, the built-in is called
checks if all constants and uses built-in sum() in that case
"""
iterable = tuple(iterable) # Fix generator polling
if len(iterable) == 1:
iterable = tuple(iterable[0]) # Fix generator polling
if not builtins.any(isinstance(elem, Expression) for elem in iterable):
return builtins.sum(iterable, **kwargs)

Expand Down

0 comments on commit 32a23d8

Please sign in to comment.