<commit_before>// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "../stabilizers/pauli_string.h"

#include "../py/base.pybind.h"
#include "../simulators/tableau_simulator.h"
#include "../stabilizers/tableau.h"
#include "tableau.pybind.h"

void pybind_pauli_string(pybind11::module &m) {
    const char *SET_ITEM_DOC = R"DOC(
       Mutates an entry in the pauli string using the encoding 0=I, 1=X, 2=Y, 3=Z.

       Examples:
           >>> import stim
           >>> p = stim.PauliString(4)
           >>> p[2] = 1
           >>> print(p)
           +__X_
           >>> p[0] = 3
           >>> p[1] = 2
           >>> p[3] = 0
           >>> print(p)
           +ZYX_
           >>> p[0] = 'I'
           >>> p[1] = 'X'
           >>> p[2] = 'Y'
           >>> p[3] = 'Z'
           >>> print(p)
           +_XYZ
           >>> p[-1] = 'Y'
           >>> print(p)
           +_XYY

       Args:
           index: The index of the pauli to return.
    )DOC";
    const char *GET_ITEM_DOC = R"DOC(
        Returns an individual Pauli or Pauli string slice from the pauli string.

        Individual Paulis are returned as an int using the encoding 0=I, 1=X, 2=Y, 3=Z.
        Slices are returned as a stim.PauliString (always with positive sign).

        Examples:
            >>> import stim
            >>> p = stim.PauliString("_XYZ")
            >>> p[2]
            2
            >>> p[-1]
            3
            >>> p[:2]
            stim.PauliString("+_X")
            >>> p[::-1]
            stim.PauliString("+ZYX_")

        Args:
            index: The index of the pauli to return or slice of paulis to return.

        Returns:
            0: Identity.
            1: Pauli X.
            2: Pauli Y.
            3: Pauli Z.
     )DOC";
    const char *MUL_DOC = R"DOC(
        Returns the product of two commuting Pauli strings.

        The integers +1 and -1 are considered to be identity Pauli strings with the given sign.

        For anti-commuting Pauli strings, use 'stim.PauliString.extended_product' instead.

        Args:
            rhs: The right hand side Pauli string.

        Examples:
            >>> import stim
            >>> p1 = stim.PauliString("_XYZ")
            >>> p2 = stim.PauliString("_ZYX")
            >>> p3 = p1 * p2
            >>> print(p3)
            +_Y_Y
            >>> stim.PauliString("XX") * stim.PauliString("ZZ")
            stim.PauliString("-YY")

        Returns:
            The product of the two Pauli strings.

        Raises:
            ValueError: The Pauli strings don't commute, or have different lengths.
    )DOC";

    pybind11::class_<PauliString>(
        m, "PauliString",
        R"DOC(
            A signed Pauli product (e.g. "+X ⊗ X ⊗ X" or "-Y ⊗ Z".

            Represents a collection of Pauli operations (I, X, Y, Z) applied pairwise to a collection of qubits.<commit_msg>Escape unicode characters in utf8 doc string (#22)<commit_after>// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "../stabilizers/pauli_string.h"

#include "../py/base.pybind.h"
#include "../simulators/tableau_simulator.h"
#include "../stabilizers/tableau.h"
#include "tableau.pybind.h"

void pybind_pauli_string(pybind11::module &m) {
    const char *SET_ITEM_DOC = R"DOC(
       Mutates an entry in the pauli string using the encoding 0=I, 1=X, 2=Y, 3=Z.

       Examples:
           >>> import stim
           >>> p = stim.PauliString(4)
           >>> p[2] = 1
           >>> print(p)
           +__X_
           >>> p[0] = 3
           >>> p[1] = 2
           >>> p[3] = 0
           >>> print(p)
           +ZYX_
           >>> p[0] = 'I'
           >>> p[1] = 'X'
           >>> p[2] = 'Y'
           >>> p[3] = 'Z'
           >>> print(p)
           +_XYZ
           >>> p[-1] = 'Y'
           >>> print(p)
           +_XYY

       Args:
           index: The index of the pauli to return.
    )DOC";
    const char *GET_ITEM_DOC = R"DOC(
        Returns an individual Pauli or Pauli string slice from the pauli string.

        Individual Paulis are returned as an int using the encoding 0=I, 1=X, 2=Y, 3=Z.
        Slices are returned as a stim.PauliString (always with positive sign).

        Examples:
            >>> import stim
            >>> p = stim.PauliString("_XYZ")
            >>> p[2]
            2
            >>> p[-1]
            3
            >>> p[:2]
            stim.PauliString("+_X")
            >>> p[::-1]
            stim.PauliString("+ZYX_")

        Args:
            index: The index of the pauli to return or slice of paulis to return.

        Returns:
            0: Identity.
            1: Pauli X.
            2: Pauli Y.
            3: Pauli Z.
     )DOC";
    const char *MUL_DOC = R"DOC(
        Returns the product of two commuting Pauli strings.

        The integers +1 and -1 are considered to be identity Pauli strings with the given sign.

        For anti-commuting Pauli strings, use 'stim.PauliString.extended_product' instead.

        Args:
            rhs: The right hand side Pauli string.

        Examples:
            >>> import stim
            >>> p1 = stim.PauliString("_XYZ")
            >>> p2 = stim.PauliString("_ZYX")
            >>> p3 = p1 * p2
            >>> print(p3)
            +_Y_Y
            >>> stim.PauliString("XX") * stim.PauliString("ZZ")
            stim.PauliString("-YY")

        Returns:
            The product of the two Pauli strings.

        Raises:
            ValueError: The Pauli strings don't commute, or have different lengths.
    )DOC";

    pybind11::class_<PauliString>(
        m, "PauliString",
        u8R"DOC(
            A signed Pauli product (e.g. "+X \u2297 X \u2297 X" or "-Y \u2297 Z".

            Represents a collection of Pauli operations (I, X, Y, Z) applied pairwise to a collection of qubits.
{'fraction_non_alphanumeric': 0.11910994764397906, 'fraction_numerical': 0.017452006980802792, 'mean_word_length': 1.7278857596191988, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 167, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2963496', 'n_tokens_mistral': 2172, 'n_tokens_neox': 2022, 'n_words': 704}