Skip to content

Commit

Permalink
Fix various documentation typos
Browse files Browse the repository at this point in the history
Fixes #630

Fixes #635

Fixes #636
  • Loading branch information
Strilanc committed Nov 20, 2023
1 parent 594d1fe commit eab1e94
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 25 deletions.
4 changes: 2 additions & 2 deletions doc/gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2748,7 +2748,7 @@ Examples:
# Reset qubit 5 into the |+> state.
RX 5

# Result multiple qubits into the |+> state.
# Reset multiple qubits into the |+> state.
RX 2 3 5
Stabilizer Generators:

Expand Down Expand Up @@ -2780,7 +2780,7 @@ Examples:
# Reset qubit 5 into the |i> state.
RY 5

# Result multiple qubits into the |i> state.
# Reset multiple qubits into the |i> state.
RY 2 3 5
Stabilizer Generators:

Expand Down
14 changes: 9 additions & 5 deletions doc/python_api_reference_vDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -9315,8 +9315,13 @@ def from_named_gate(
def from_numpy(
self,
*,
bit_packed: bool = False,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
x2x: np.ndarray,
x2z: np.ndarray,
z2x: np.ndarray,
z2z: np.ndarray,
x_signs: Optional[np.ndarray] = None,
z_signs: Optional[np.ndarray] = None,
) -> stim.Tableau:
"""Creates a tableau from numpy arrays x2x, x2z, z2x, z2z, x_signs, and z_signs.
The x2x, x2z, z2x, z2z arrays are the four quadrants of the table defined in
Expand Down Expand Up @@ -9368,7 +9373,7 @@ def from_numpy(
... x2z=np.array([[0, 0], [0, 0]], dtype=np.bool_),
... z2z=np.array([[1, 0], [1, 1]], dtype=np.bool_),
... )
>>> print(repr(tableau))
>>> tableau
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("+XX"),
Expand All @@ -9382,15 +9387,14 @@ def from_numpy(
>>> tableau == stim.Tableau.from_named_gate("CNOT")
True
>>> tableau = stim.Tableau.from_numpy(
>>> stim.Tableau.from_numpy(
... x2x=np.array([[9], [5], [7], [6]], dtype=np.uint8),
... x2z=np.array([[13], [13], [0], [3]], dtype=np.uint8),
... z2x=np.array([[8], [5], [9], [15]], dtype=np.uint8),
... z2z=np.array([[6], [11], [2], [3]], dtype=np.uint8),
... x_signs=np.array([7], dtype=np.uint8),
... z_signs=np.array([9], dtype=np.uint8),
... )
>>> print(repr(tableau))
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("-Y_ZY"),
Expand Down
14 changes: 9 additions & 5 deletions doc/stim.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7156,8 +7156,13 @@ class Tableau:
def from_numpy(
self,
*,
bit_packed: bool = False,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
x2x: np.ndarray,
x2z: np.ndarray,
z2x: np.ndarray,
z2z: np.ndarray,
x_signs: Optional[np.ndarray] = None,
z_signs: Optional[np.ndarray] = None,
) -> stim.Tableau:
"""Creates a tableau from numpy arrays x2x, x2z, z2x, z2z, x_signs, and z_signs.
The x2x, x2z, z2x, z2z arrays are the four quadrants of the table defined in
Expand Down Expand Up @@ -7209,7 +7214,7 @@ class Tableau:
... x2z=np.array([[0, 0], [0, 0]], dtype=np.bool_),
... z2z=np.array([[1, 0], [1, 1]], dtype=np.bool_),
... )
>>> print(repr(tableau))
>>> tableau
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("+XX"),
Expand All @@ -7223,15 +7228,14 @@ class Tableau:
>>> tableau == stim.Tableau.from_named_gate("CNOT")
True
>>> tableau = stim.Tableau.from_numpy(
>>> stim.Tableau.from_numpy(
... x2x=np.array([[9], [5], [7], [6]], dtype=np.uint8),
... x2z=np.array([[13], [13], [0], [3]], dtype=np.uint8),
... z2x=np.array([[8], [5], [9], [15]], dtype=np.uint8),
... z2z=np.array([[6], [11], [2], [3]], dtype=np.uint8),
... x_signs=np.array([7], dtype=np.uint8),
... z_signs=np.array([9], dtype=np.uint8),
... )
>>> print(repr(tableau))
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("-Y_ZY"),
Expand Down
14 changes: 9 additions & 5 deletions glue/python/src/stim/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7156,8 +7156,13 @@ class Tableau:
def from_numpy(
self,
*,
bit_packed: bool = False,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
x2x: np.ndarray,
x2z: np.ndarray,
z2x: np.ndarray,
z2z: np.ndarray,
x_signs: Optional[np.ndarray] = None,
z_signs: Optional[np.ndarray] = None,
) -> stim.Tableau:
"""Creates a tableau from numpy arrays x2x, x2z, z2x, z2z, x_signs, and z_signs.
The x2x, x2z, z2x, z2z arrays are the four quadrants of the table defined in
Expand Down Expand Up @@ -7209,7 +7214,7 @@ class Tableau:
... x2z=np.array([[0, 0], [0, 0]], dtype=np.bool_),
... z2z=np.array([[1, 0], [1, 1]], dtype=np.bool_),
... )
>>> print(repr(tableau))
>>> tableau
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("+XX"),
Expand All @@ -7223,15 +7228,14 @@ class Tableau:
>>> tableau == stim.Tableau.from_named_gate("CNOT")
True
>>> tableau = stim.Tableau.from_numpy(
>>> stim.Tableau.from_numpy(
... x2x=np.array([[9], [5], [7], [6]], dtype=np.uint8),
... x2z=np.array([[13], [13], [0], [3]], dtype=np.uint8),
... z2x=np.array([[8], [5], [9], [15]], dtype=np.uint8),
... z2z=np.array([[6], [11], [2], [3]], dtype=np.uint8),
... x_signs=np.array([7], dtype=np.uint8),
... z_signs=np.array([9], dtype=np.uint8),
... )
>>> print(repr(tableau))
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("-Y_ZY"),
Expand Down
4 changes: 2 additions & 2 deletions src/stim/circuit/gate_data_collapsing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ Parens Arguments:
# Reset qubit 5 into the |+> state.
RX 5
# Result multiple qubits into the |+> state.
# Reset multiple qubits into the |+> state.
RX 2 3 5
)MARKDOWN",
.unitary_data = {},
Expand Down Expand Up @@ -410,7 +410,7 @@ Parens Arguments:
# Reset qubit 5 into the |i> state.
RY 5
# Result multiple qubits into the |i> state.
# Reset multiple qubits into the |i> state.
RY 2 3 5
)MARKDOWN",
.unitary_data = {},
Expand Down
4 changes: 2 additions & 2 deletions src/stim/stabilizers/conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ bool stim::try_disjoint_to_independent_xyz_errors_approx(

double stim::depolarize1_probability_to_independent_per_channel_probability(double p) {
if (p > 0.75) {
throw std::invalid_argument("disjoint_to_independent_depolarize1 with p>0.75; p=" + std::to_string(p));
throw std::invalid_argument("depolarize1_probability_to_independent_per_channel_probability with p>0.75; p=" + std::to_string(p));
}
return 0.5 - 0.5 * sqrt(1 - (4 * p) / 3);
}

double stim::depolarize2_probability_to_independent_per_channel_probability(double p) {
if (p > 0.9375) {
throw std::invalid_argument("disjoint_to_independent_depolarize1 with p>15.0/16.0; p=" + std::to_string(p));
throw std::invalid_argument("depolarize2_probability_to_independent_per_channel_probability with p>15.0/16.0; p=" + std::to_string(p));
}
return 0.5 - 0.5 * pow(1 - (16 * p) / 15, 0.125);
}
Expand Down
7 changes: 3 additions & 4 deletions src/stim/stabilizers/tableau.pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ void stim_pybind::pybind_tableau_methods(pybind11::module &m, pybind11::class_<T
pybind11::arg("x_signs") = pybind11::none(),
pybind11::arg("z_signs") = pybind11::none(),
clean_doc_string(R"DOC(
@signature def from_numpy(self, *, bit_packed: bool = False) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
@signature def from_numpy(self, *, x2x: np.ndarray, x2z: np.ndarray, z2x: np.ndarray, z2z: np.ndarray, x_signs: Optional[np.ndarray] = None, z_signs: Optional[np.ndarray] = None) -> stim.Tableau:
Creates a tableau from numpy arrays x2x, x2z, z2x, z2z, x_signs, and z_signs.
Expand Down Expand Up @@ -589,7 +589,7 @@ void stim_pybind::pybind_tableau_methods(pybind11::module &m, pybind11::class_<T
... x2z=np.array([[0, 0], [0, 0]], dtype=np.bool_),
... z2z=np.array([[1, 0], [1, 1]], dtype=np.bool_),
... )
>>> print(repr(tableau))
>>> tableau
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("+XX"),
Expand All @@ -603,15 +603,14 @@ void stim_pybind::pybind_tableau_methods(pybind11::module &m, pybind11::class_<T
>>> tableau == stim.Tableau.from_named_gate("CNOT")
True
>>> tableau = stim.Tableau.from_numpy(
>>> stim.Tableau.from_numpy(
... x2x=np.array([[9], [5], [7], [6]], dtype=np.uint8),
... x2z=np.array([[13], [13], [0], [3]], dtype=np.uint8),
... z2x=np.array([[8], [5], [9], [15]], dtype=np.uint8),
... z2z=np.array([[6], [11], [2], [3]], dtype=np.uint8),
... x_signs=np.array([7], dtype=np.uint8),
... z_signs=np.array([9], dtype=np.uint8),
... )
>>> print(repr(tableau))
stim.Tableau.from_conjugated_generators(
xs=[
stim.PauliString("-Y_ZY"),
Expand Down

0 comments on commit eab1e94

Please sign in to comment.