Repository navigation
Conversation
x[[{2, 5}]] = v crashed (SubExpression returned None for a
ListExpression position), x[[All, 1]] = v assigned to x[[1]] instead of
the first element of every row, x[[-1]] = v wrote the wrong element, and
a part that does not exist raised IndexError after some parts had
already been changed.
Positions are now resolved and checked before anything is replaced:
a list of positions, All and a Span select several parts, negative
positions count from the end, and a missing part gives Part::partw and
leaves the value unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
l[[0]] = f with l a List, m[[2, 0]] = g on a nested List, and k[[0]] = List crashed with a TypeError: a List cannot take another head in place. The part is now replaced by a new expression with the new head. The value assigned to is held while it changes, so that the value itself can be replaced as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b = a; b[[2, 1]] = 9 changed a too, and k[] := (w = {1, {2}};
w[[2, 1]] = 5; w) changed the definition of k: the parts on the way to
the assigned position were changed in place, though they may be shared
with other values and definitions. They are now copied first.
A ListExpression changed with set_element works out again whether it
is literal. Span positions counted from the end, and spans with a
negative step, now select the parts WMA selects.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pa[[{2, f[x]}]] = 5 raised an AttributeError; it now gives the message
WMA gives and leaves pa unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t again Each p[[i]] = v on a long list went over all its elements several times: set_element worked out again whether the list is literal, and afterwards its elements properties and its symbol cache were rebuilt, and the list was evaluated element by element, because they had been cleared. ListExpression.set_element now updates the literal value, the elements properties and the cache from the old ones and the new element; copies of a list keep them too. A Fisher-Yates shuffle of Range[1000] by Part assignments (Combinatorica's RandomPermutation) took 11.7 s with the copy on write of this branch and 9.3 s on master; it now takes 2.8 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
part[[-4]] = 0 on a list of three elements turned -4 into position 0 and replaced the head, giving 0[1, 2, 3]. A negative position now has to be between -Length and -1, as in WMA; position 0 is reached only as 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-part-assign-shared
205762a to
3d23609
Compare
|
Merged into branch directly. |
|
I pushed two commits to this branch after a review. Each commit message has the details.
The
Spans in Part assignment (also wrong on master):
Copying:
Left as is on purpose: The list, assignment, core and evaluation tests pass locally (709 passed, 6 xfailed). The full pytest and doctest run is still going. 🤖 Generated with Claude Code |
Resolve the merge conflict by accepting new tests that have been added to master.
Perform some Ruff and mypy fixes that are not in a merge to a follow-on PR that has
mathics.core.listruff and mypy changes.