Skip to content

Commit

Permalink
tweak type
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Nov 30, 2023
1 parent 2163241 commit 6c05272
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
10 changes: 7 additions & 3 deletions doc/python_api_reference_vDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -8031,7 +8031,7 @@ def __imul__(
# (in class stim.PauliString)
def __init__(
self,
arg: Union[None, int, str, stim.PauliString, Iterable[int]] = None,
arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None,
/,
) -> None:
"""Initializes a stim.PauliString from the given argument.
Expand All @@ -8047,8 +8047,9 @@ def __init__(
int: initializes an identity Pauli string of the given length.
str: initializes by parsing the given text.
stim.PauliString: initializes a copy of the given Pauli string.
Iterable[int]: initializes by interpreting each integer as a Pauli
using the convention 0=I, 1=X, 2=Y, 3=Z.
Iterable: initializes by interpreting each item as a Pauli.
Each item can be a single-qubit Pauli string (like "X"),
or an integer. Integers use the convention 0=I, 1=X, 2=Y, 3=Z.
Examples:
>>> import stim
Expand All @@ -8067,6 +8068,9 @@ def __init__(
>>> stim.PauliString([0, 1, 3, 2])
stim.PauliString("+_XZY")
>>> stim.PauliString("X" for _ in range(4))
stim.PauliString("+XXXX")
"""
```

Expand Down
10 changes: 7 additions & 3 deletions doc/stim.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6157,7 +6157,7 @@ class PauliString:
"""
def __init__(
self,
arg: Union[None, int, str, stim.PauliString, Iterable[int]] = None,
arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None,
/,
) -> None:
"""Initializes a stim.PauliString from the given argument.
Expand All @@ -6173,8 +6173,9 @@ class PauliString:
int: initializes an identity Pauli string of the given length.
str: initializes by parsing the given text.
stim.PauliString: initializes a copy of the given Pauli string.
Iterable[int]: initializes by interpreting each integer as a Pauli
using the convention 0=I, 1=X, 2=Y, 3=Z.
Iterable: initializes by interpreting each item as a Pauli.
Each item can be a single-qubit Pauli string (like "X"),
or an integer. Integers use the convention 0=I, 1=X, 2=Y, 3=Z.
Examples:
>>> import stim
Expand All @@ -6193,6 +6194,9 @@ class PauliString:
>>> stim.PauliString([0, 1, 3, 2])
stim.PauliString("+_XZY")
>>> stim.PauliString("X" for _ in range(4))
stim.PauliString("+XXXX")
"""
def __itruediv__(
self,
Expand Down
10 changes: 7 additions & 3 deletions glue/python/src/stim/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6157,7 +6157,7 @@ class PauliString:
"""
def __init__(
self,
arg: Union[None, int, str, stim.PauliString, Iterable[int]] = None,
arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None,
/,
) -> None:
"""Initializes a stim.PauliString from the given argument.
Expand All @@ -6173,8 +6173,9 @@ class PauliString:
int: initializes an identity Pauli string of the given length.
str: initializes by parsing the given text.
stim.PauliString: initializes a copy of the given Pauli string.
Iterable[int]: initializes by interpreting each integer as a Pauli
using the convention 0=I, 1=X, 2=Y, 3=Z.
Iterable: initializes by interpreting each item as a Pauli.
Each item can be a single-qubit Pauli string (like "X"),
or an integer. Integers use the convention 0=I, 1=X, 2=Y, 3=Z.
Examples:
>>> import stim
Expand All @@ -6193,6 +6194,9 @@ class PauliString:
>>> stim.PauliString([0, 1, 3, 2])
stim.PauliString("+_XZY")
>>> stim.PauliString("X" for _ in range(4))
stim.PauliString("+XXXX")
"""
def __itruediv__(
self,
Expand Down
10 changes: 7 additions & 3 deletions src/stim/stabilizers/pauli_string.pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void stim_pybind::pybind_pauli_string_methods(pybind11::module &m, pybind11::cla
pybind11::arg("other") = pybind11::none(),
pybind11::arg("pauli_indices") = pybind11::none(),
clean_doc_string(R"DOC(
@signature def __init__(self, arg: Union[None, int, str, stim.PauliString, Iterable[int]] = None, /) -> None:
@signature def __init__(self, arg: Union[None, int, str, stim.PauliString, Iterable[Union[int, 'Literal["_", "I", "X", "Y", "Z"]']]] = None, /) -> None:
Initializes a stim.PauliString from the given argument.
When given a string, the string is parsed as a pauli string. The string can
Expand All @@ -418,8 +418,9 @@ void stim_pybind::pybind_pauli_string_methods(pybind11::module &m, pybind11::cla
int: initializes an identity Pauli string of the given length.
str: initializes by parsing the given text.
stim.PauliString: initializes a copy of the given Pauli string.
Iterable[int]: initializes by interpreting each integer as a Pauli
using the convention 0=I, 1=X, 2=Y, 3=Z.
Iterable: initializes by interpreting each item as a Pauli.
Each item can be a single-qubit Pauli string (like "X"),
or an integer. Integers use the convention 0=I, 1=X, 2=Y, 3=Z.
Examples:
>>> import stim
Expand All @@ -438,6 +439,9 @@ void stim_pybind::pybind_pauli_string_methods(pybind11::module &m, pybind11::cla
>>> stim.PauliString([0, 1, 3, 2])
stim.PauliString("+_XZY")
>>> stim.PauliString("X" for _ in range(4))
stim.PauliString("+XXXX")
)DOC")
.data());

Expand Down
1 change: 1 addition & 0 deletions src/stim/stabilizers/pauli_string_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ def test_backwards_compatibility_init():
assert stim.PauliString([1, 2, 3]) == stim.PauliString("+XYZ")
assert stim.PauliString("XYZ") == stim.PauliString("+XYZ")
assert stim.PauliString(stim.PauliString("XYZ")) == stim.PauliString("+XYZ")
assert stim.PauliString("X" for _ in range(4)) == stim.PauliString("+XXXX")

# These keywords have been removed from the documentation and the .pyi, but
# their functionality needs to be maintained for backwards compatibility.
Expand Down

0 comments on commit 6c05272

Please sign in to comment.