Repository navigation
Table: do not mark the result as fully evaluated; a literal element is fully evaluated - #2020
Merged
Merged
Conversation
Table.get_result() gave its list ElementsProperties(elements_fully_evaluated=True).
ListExpression then never evaluated the elements again, even when they depend
on definitions made later:
l = Table[x, {1}]; x = 1; l (* gave {x}; WMA: {1} *)
l = Table[f[y], {1}]; f[y_] := 7; l (* gave {f[y]}; WMA: {7} *)
The list now works out its properties from its elements, as any other list does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Map over an empty list gives {} with pessimistic elements properties
(elements_fully_evaluated=False), although {} is literal. A list holding such
an element is itself literal, and _build_elements_properties() then failed on
`assert self.elements_properties.elements_fully_evaluated`:
{f /@ {}} (* AssertionError; WMA: {{}} *)
The previous commit makes Table build its list this way too, so that
Table[f /@ {}, {2}] and Strickland's TodaChecks.m crashed as well.
_build_elements_properties() and convert_expression_elements() now take a
literal element as fully evaluated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The property is_fully_evaluated should be set to True when Table produces a List of literal elements (like a list of numbers). This should be checked at creation time. |
As suggested in review: when all the elements Table produces are literal, like a list of numbers, the list is marked as fully evaluated when Table builds it. Other tables still get their properties from ListExpression. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
@mmatera thanks, done in the latest commit. When every element Table produces is literal ( |
Member
|
LGTM thanks @tombouctou and @mmatera |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tablegave its resultElementsProperties(elements_fully_evaluated=True). AListExpressionwith that flag never evaluates its elements again. So a table whose elements depend on a definition made later keeps its old value:Rangewith symbolic bounds andArrayalready behave like WMA. OnlyTableset the flag unconditionally.With this PR,
Table.get_resultjust builds aListExpressionfrom the elements and lets it work out its properties, as any other list does. A table of literals (numbers, strings) is still marked as fully evaluated, because that comes from the elements themselves.Second commit: a literal element is fully evaluated. Building the list this way exposed a crash that is already on master.
Mapover an empty list gives{}with pessimistic properties (elements_fully_evaluated=False), although{}is literal. A list that holds such an element is itself literal, and_build_elements_propertiesthen fails its assertion:_build_elements_propertiesandconvert_expression_elementsnow treat a literal element as fully evaluated, whatever its own properties say.Checks:
test_table_is_evaluated_againintest/builtin/list/test_constructing.py(now including both cases above) fails on master and passes here. Full pytest and doctests pass.🤖 Generated with Claude Code