loqs.tools.migrate.flags¶
Patterns whose replacement is a semantic change or ambiguous.
<OldCastableClass>.cast(...): removed entirely in v1.2. ForInstructionLabelandSyndromeLabel, confidently rewritten to.from_raw(...)(same call signature and dispatch semantics). For the other 14 castable classes (InstructionStack,DictModel, etc.), their replacement is a direct constructor call, not a pure method rename, so those are flagged only. All casting patterns are scoped to the specific classes that had a real.cast()(derived fromRENAMES's own*CastableTypesentries, not a bare.cast(scan), since a bare scan collides with unrelated third-party.cast()methods with the exact same name (pygsti.circuits.Circuit.cast,pygsti.evotypes.Evotype.cast), which aren't LoQS's removed API at all.include_idles=/reference_round_Z=/reference_round_X=passed to acreate_qec_code(...)-style call: replaced in v1.2 byidle_layout=/reference_round_mode_Z=/reference_round_mode_X=, but these are semantic changes, not pure renames (a boolean doesn't map onto the new parameter's meaning automatically). Scoped to calls whose function name ends increate_qec_codespecifically, not a bareinclude_idles=scan, since several other, unrelated, still-currentinclude_idles: boolparameters exist on lower-level circuit-building helpers throughoutloqs/codepacks/codepack_surf17_multipatch.py/codepack_surf17_surgery.pythat this rename doesn't touch.- A bare
"Iz"string literal: likely an old instrument-name reference to what's now"Imrz"(renamed in v1.2), but this is a plain string, not an identifier reference, so a blind rewrite risks matching unrelated text that just happens to contain the same two characters -- flagged by default, but rewritten for real when the caller opts in (the CLI's--rename-Iz), viarewrite_iz_literal().
STIMDictNoiseModel real code references, and any RepTuple construction
reptuple can't confidently resolve to a concrete
class, are flagged too, but via renames's own
RENAMES table (both are overridden there to a deleted-outright entry)
rather than a pattern here -- see that module's docstring for why a blind
rename would be actively wrong for these two specifically.
Functions¶
<OldCastableClass>.cast(...): removed entirely in v1.2. ForInstructionLabelandSyndromeLabel, confidently rewritten to.from_raw(...)(same call signature and dispatch semantics). For the other 14 castable classes (InstructionStack,DictModel, etc.), their replacement is a direct constructor call, not a pure method rename, so those are flagged only. All casting patterns are scoped to the specific classes that had a real.cast()(derived fromRENAMES's own*CastableTypesentries, not a bare.cast(scan), since a bare scan collides with unrelated third-party.cast()methods with the exact same name (pygsti.circuits.Circuit.cast,pygsti.evotypes.Evotype.cast), which aren't LoQS's removed API at all.include_idles=/reference_round_Z=/reference_round_X=passed to acreate_qec_code(...)-style call: replaced in v1.2 byidle_layout=/reference_round_mode_Z=/reference_round_mode_X=, but these are semantic changes, not pure renames (a boolean doesn't map onto the new parameter's meaning automatically). Scoped to calls whose function name ends increate_qec_codespecifically, not a bareinclude_idles=scan, since several other, unrelated, still-currentinclude_idles: boolparameters exist on lower-level circuit-building helpers throughoutloqs/codepacks/codepack_surf17_multipatch.py/codepack_surf17_surgery.pythat this rename doesn't touch.- A bare
"Iz"string literal: likely an old instrument-name reference to what's now"Imrz"(renamed in v1.2), but this is a plain string, not an identifier reference, so a blind rewrite risks matching unrelated text that just happens to contain the same two characters -- flagged by default, but rewritten for real when the caller opts in (the CLI's--rename-Iz), viarewrite_iz_literal().
STIMDictNoiseModel real code references, and any RepTuple construction
reptuple can't confidently resolve to a concrete
class, are flagged too, but via renames's own
RENAMES table (both are overridden there to a deleted-outright entry)
rather than a pattern here -- see that module's docstring for why a blind
rename would be actively wrong for these two specifically.
detect_flagged_patterns ¶
detect_flagged_patterns(source: str, *, rename_iz: bool = False) -> list[ManualReviewItem]
Scan source for every pattern described in this module's
docstring, returning one ManualReviewItem per match (not per
pattern -- a pattern appearing 3 times produces 3 items, each with
its own line number).
rename_iz should be True exactly when rewrite_iz_literal()
already ran over the same source -- the "Iz" literal pattern is
skipped here in that case, since it was already rewritten rather than
left to flag.
<OldCastableClass>.cast(...): removed entirely in v1.2. ForInstructionLabelandSyndromeLabel, confidently rewritten to.from_raw(...)(same call signature and dispatch semantics). For the other 14 castable classes (InstructionStack,DictModel, etc.), their replacement is a direct constructor call, not a pure method rename, so those are flagged only. All casting patterns are scoped to the specific classes that had a real.cast()(derived fromRENAMES's own*CastableTypesentries, not a bare.cast(scan), since a bare scan collides with unrelated third-party.cast()methods with the exact same name (pygsti.circuits.Circuit.cast,pygsti.evotypes.Evotype.cast), which aren't LoQS's removed API at all.include_idles=/reference_round_Z=/reference_round_X=passed to acreate_qec_code(...)-style call: replaced in v1.2 byidle_layout=/reference_round_mode_Z=/reference_round_mode_X=, but these are semantic changes, not pure renames (a boolean doesn't map onto the new parameter's meaning automatically). Scoped to calls whose function name ends increate_qec_codespecifically, not a bareinclude_idles=scan, since several other, unrelated, still-currentinclude_idles: boolparameters exist on lower-level circuit-building helpers throughoutloqs/codepacks/codepack_surf17_multipatch.py/codepack_surf17_surgery.pythat this rename doesn't touch.- A bare
"Iz"string literal: likely an old instrument-name reference to what's now"Imrz"(renamed in v1.2), but this is a plain string, not an identifier reference, so a blind rewrite risks matching unrelated text that just happens to contain the same two characters -- flagged by default, but rewritten for real when the caller opts in (the CLI's--rename-Iz), viarewrite_iz_literal().
STIMDictNoiseModel real code references, and any RepTuple construction
reptuple can't confidently resolve to a concrete
class, are flagged too, but via renames's own
RENAMES table (both are overridden there to a deleted-outright entry)
rather than a pattern here -- see that module's docstring for why a blind
rename would be actively wrong for these two specifically.
rewrite_cast_to_from_raw ¶
rewrite_cast_to_from_raw(source: str) -> MigrationResult
Rewrite InstructionLabel.cast(...) and SyndromeLabel.cast(...) to
their .from_raw(...) equivalents. These two classes have a confident
replacement with the same call signature and dispatch semantics;
other castable classes' replacements are direct constructor calls and
remain flag-only.
<OldCastableClass>.cast(...): removed entirely in v1.2. ForInstructionLabelandSyndromeLabel, confidently rewritten to.from_raw(...)(same call signature and dispatch semantics). For the other 14 castable classes (InstructionStack,DictModel, etc.), their replacement is a direct constructor call, not a pure method rename, so those are flagged only. All casting patterns are scoped to the specific classes that had a real.cast()(derived fromRENAMES's own*CastableTypesentries, not a bare.cast(scan), since a bare scan collides with unrelated third-party.cast()methods with the exact same name (pygsti.circuits.Circuit.cast,pygsti.evotypes.Evotype.cast), which aren't LoQS's removed API at all.include_idles=/reference_round_Z=/reference_round_X=passed to acreate_qec_code(...)-style call: replaced in v1.2 byidle_layout=/reference_round_mode_Z=/reference_round_mode_X=, but these are semantic changes, not pure renames (a boolean doesn't map onto the new parameter's meaning automatically). Scoped to calls whose function name ends increate_qec_codespecifically, not a bareinclude_idles=scan, since several other, unrelated, still-currentinclude_idles: boolparameters exist on lower-level circuit-building helpers throughoutloqs/codepacks/codepack_surf17_multipatch.py/codepack_surf17_surgery.pythat this rename doesn't touch.- A bare
"Iz"string literal: likely an old instrument-name reference to what's now"Imrz"(renamed in v1.2), but this is a plain string, not an identifier reference, so a blind rewrite risks matching unrelated text that just happens to contain the same two characters -- flagged by default, but rewritten for real when the caller opts in (the CLI's--rename-Iz), viarewrite_iz_literal().
STIMDictNoiseModel real code references, and any RepTuple construction
reptuple can't confidently resolve to a concrete
class, are flagged too, but via renames's own
RENAMES table (both are overridden there to a deleted-outright entry)
rather than a pattern here -- see that module's docstring for why a blind
rename would be actively wrong for these two specifically.
rewrite_iz_literal ¶
rewrite_iz_literal(source: str) -> MigrationResult
Rewrite every bare "Iz"/'Iz' string literal to "Imrz"/'Imrz',
preserving its original quote style. Opt-in only (the CLI's
--rename-Iz) -- see the module docstring for why this isn't done by
default. No manual-review item is produced for a line this rewrites;
unlike the patch_label inst_kwarg case in
labels, nothing else needs a follow-up
once the string itself is renamed.