Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mathics/builtin/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ class OutputSizeLimit(Predefined):
>> $OutputSizeLimit = 10;
>> Table[i, {i, 1, 100}]
= {1, <<98>>, 100}
#> {}
= {}
>> $OutputSizeLimit = Infinity;
"""

Expand All @@ -421,6 +423,3 @@ class OutputSizeLimit(Predefined):
rules = {
'$OutputSizeLimit': str(value),
}

def evaluate(self, evaluation):
return Integer(self.value)
9 changes: 5 additions & 4 deletions mathics/core/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,7 @@ def make(self, items, form, segment=None):
capacity = state.capacity

if capacity is None or len(items) < 1:
return self._unlimited(items, form, segment)
return self._unlimited.make(items, form, segment)

left_leaves = []
right_leaves = []
Expand Down Expand Up @@ -2409,6 +2409,7 @@ def make(self, items, form, segment=None):
delay_break = 0

depth = state.depth

sum_of_costs = 0

for i, (item, push) in enumerate(_interleave(*from_sides)):
Expand Down Expand Up @@ -2465,11 +2466,11 @@ def _evaluate(self, item, form, **kwargs):

box = Expression('MakeBoxes', item, form).evaluate(self._evaluation)

# estimate the cost of the output related to box. always calling boxes_to_xml here is
# estimate the cost of the output related to box. always calling boxes_to_text here is
# the simple solution; the problem is that it's redundant, as for {{{a}, b}, c}, we'd
# call boxes_to_xml first on {a}, then on {{a}, b}, then on {{{a}, b}, c}. a good fix
# call boxes_to_text first on {a}, then on {{a}, b}, then on {{{a}, b}, c}. a good fix
# is not simple though, so let's keep it this way for now.
cost = len(box.boxes_to_xml(evaluation=self._evaluation)) # evaluate len as XML
cost = len(box.boxes_to_text(evaluation=self._evaluation))

return box, cost
finally:
Expand Down