quantumlib / Stim

A fast stabilizer circuit library.
Apache License 2.0
356 stars 107 forks source link

Add `dict[int, int | str]` and `dict[str, int | Iterable[int]]` argument support to `stim.PauliString.__init__` #852

Open Strilanc opened 2 weeks ago

Strilanc commented 2 weeks ago

For example

assert stim.PauliString({5: "X", 7: "Y"}) == stim.PauliString("_____X_Y")
assert stim.PauliString({"X": 5, "Y": [6, 7]}) == stim.PauliString("_____XYY")
with pytest.raises(ValueError, match="qubit specified twice"):
    stim.PauliString({"X": 0, "Y": 0})

Could also accept stim.GateTarget lists.