Skip to content

Commit b8fec36

Browse files
committed
fix: CTrunc bug
1 parent edae8dc commit b8fec36

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

modules/FEDeriK/Truncation.m

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Returns list of Associations (complete index->field mappings for surviving terms
214214
);
215215

216216
LTrunc[setup_, expr_FEx] :=
217-
Join @@ Map[CTrunc[setup, #]&, List @@ expr];
217+
Join @@ Map[LTrunc[setup, #]&, List @@ expr];
218218

219219
(* LTrunc returns a list of bare lists (each = one surviving term's factors).
220220
FTruncate handles wrapping back into FTerm/FEx after BalancedMap.
@@ -657,15 +657,29 @@ Returns list of Associations (complete index->field mappings for surviving terms
657657
Module[{compatible},
658658
compatible = Select[alts, And @@ MapThread[(#2[[1]] === AnyField || #1 === #2)&, {List @@ #, List @@ partials[[qi]]}]&];
659659
If[compatible =!= {},
660-
current =
661-
Plus @@
662-
Map[
663-
Module[{rules = buildCTruncResolveRules[#]},
664-
(current /. partials[[qi]] -> #) /. rules
665-
]&
666-
,
667-
compatible
668-
];
660+
(*Split current into terms that contain the partial and terms that do not.
661+
Resolve rules must only be applied to the terms WITH the partial,
662+
otherwise they leak into unrelated branches and corrupt AnyField slots
663+
that should be resolved by a different alternative later.*)
664+
Module[{withPartial, withoutPartial},
665+
If[Head[current] === Plus,
666+
withPartial = Plus @@ Select[List @@ current, !FreeQ[#, partials[[qi]]]&];
667+
withoutPartial = Plus @@ Select[List @@ current, FreeQ[#, partials[[qi]]]&];
668+
,
669+
withPartial = current;
670+
withoutPartial = 0;
671+
];
672+
current =
673+
withoutPartial +
674+
Plus @@
675+
Map[
676+
Module[{rules = buildCTruncResolveRules[#]},
677+
(withPartial /. partials[[qi]] -> #) /. rules
678+
]&
679+
,
680+
compatible
681+
];
682+
];
669683
current = Distribute[current, Plus, NonCommutativeMultiply];
670684
current = current /. vertexKillRules;
671685
current = current /. x_NonCommutativeMultiply /; !FreeQ[x, 0] :> 0;

modules/TRACY/Cache.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
FClearTraceCache[str_String] :=
4242
Module[{},
43-
If[StringContainsQ[str, ".."] || StringMatchQ[str, ("/" | "\\" | LetterCharacter ~~ ":") ~~ ___],
43+
If[StringContainsQ[str, ".."] || StringMatchQ[str, ("/" | "\\" | (LetterCharacter ~~ ":")) ~~ ___],
4444
Message[FClearTraceCache::invalidPath, str];
4545
Abort[]
4646
];

0 commit comments

Comments
 (0)