Skip to content

Commit

Permalink
Make code compliant with new linting and formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
stand-by committed Jul 22, 2024
1 parent 177ecbb commit b328a92
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [X] PauliString
- [ ] PauliOp
- [ ] SummedPauliOp
- [ ] Figure out the tranpose non-sense or support both (some functions take the transpose of the states and others don't)
- [ ] Figure out the transpose non-sense or support both (some functions take the transpose of the states and others don't)
- [ ] Clean up `apply_batch` we shouldn't need to pass a coeff
- [ ] Clean up tests
- [ ] Add apply method to SummedPauliOp that takes precomputed weighted data
Expand Down
2 changes: 1 addition & 1 deletion fast_pauli/cpp/include/__pauli_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ template <std::floating_point T> struct PauliOp {
ps.apply_batch(new_states_local, states, c);
}

// Do the reduction and tranpose back
// Do the reduction and transpose back
#pragma omp for schedule(static) collapse(2)
for (size_t i = 0; i < new_states.extent(0); ++i) {
for (size_t t = 0; t < new_states.extent(1); ++t) {
Expand Down
2 changes: 1 addition & 1 deletion fast_pauli/cpp/include/__pauli_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ struct PauliString {
* columns
*
* @tparam T The floating point base to use for all the complex numbers
* @param new_states_T The outpus states after applying the PauliString
* @param new_states_T The output states after applying the PauliString
* (n_data x n_dim)
* @param states_T THe original states to apply the PauliString to (n_data x
* n_dim)
Expand Down
2 changes: 1 addition & 1 deletion fast_pauli/cpp/tests/test_pauli_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ TEST_CASE("test apply batch") {
size_t const n_states = 10;

// Testing each of these pauli strings individually
// NOTE: apply_batch takes the tranpose of the states and new_states
// NOTE: apply_batch takes the transpose of the states and new_states
for (PauliString ps : {"IXYZ", "YYIX", "XXYIYZ", "IZIXYYZ"}) {
size_t const dims = ps.dims();

Expand Down
2 changes: 1 addition & 1 deletion fast_pauli/py/pypauli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np


def pauli_matrices() -> dict:
def pauli_matrices() -> dict[str | int, np.ndarray]:
"""Provide a dictionary containing the Pauli matrices.
The Pauli matrices are a set of 2x2 matrices commonly used in quantum mechanics.
Expand Down
2 changes: 1 addition & 1 deletion fast_pauli/py/pypauli/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def compose_sparse_pauli(string: str) -> tuple[np.ndarray, np.ndarray]:
return cols, vals


def compose_sparse_diag_pauli(string) -> np.ndarray:
def compose_sparse_diag_pauli(string: str) -> np.ndarray:
"""Produce sparse representation of diagonal pauli string.
Args:
Expand Down
20 changes: 10 additions & 10 deletions fast_pauli/py/tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@


@pytest.fixture
def paulis():
def paulis() -> dict[str | int, np.ndarray]:
"""Fixture to provide dict with Pauli matrices."""
return pauli_matrices()
return pauli_matrices() # type: ignore


def test_pauli_string(paulis):
def test_pauli_string(paulis: dict) -> None:
"""Test the PauliString class."""
for p in ["I", "X", "Y", "Z"]:
ps = PauliString(p)
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_pauli_string(paulis):
assert PauliString("ZIXIZYXXY").weight == 7


def test_sparse_pauli_composer(paulis):
def test_sparse_pauli_composer(paulis: dict) -> None:
"""Test sparsepauli composer functions."""
ps = PauliString("II")
assert ps.dim == 4
Expand Down Expand Up @@ -104,23 +104,23 @@ def test_sparse_pauli_composer(paulis):
)


def test_sparse_pauli_composer_equivalence():
def test_sparse_pauli_composer_equivalence() -> None:
"""Test the equivalence of sparse Pauli composer with naive method."""
for c in ["I", "X", "Y", "Z"]:
np.testing.assert_array_equal(
PauliString(c).dense(),
naive_pauli_converter(c),
)

for s in permutations("XYZ", 2):
s = "".join(s)
for p2 in permutations("XYZ", 2):
s = "".join(p2)
np.testing.assert_array_equal(
PauliString(s).dense(),
naive_pauli_converter(s),
)

for s in permutations("IXYZ", 3):
s = "".join(s)
for p3 in permutations("IXYZ", 3):
s = "".join(p3)
np.testing.assert_array_equal(
PauliString(s).dense(),
naive_pauli_converter(s),
Expand All @@ -138,7 +138,7 @@ def test_sparse_pauli_composer_equivalence():
np.testing.assert_array_equal(PauliString(s).dense(), naive_pauli_converter(s))


def test_sparse_pauli_multiply():
def test_sparse_pauli_multiply() -> None:
"""Test the equivalence of multiply method that relies on sparse Pauli composer."""
rng = np.random.default_rng(321)

Expand Down

0 comments on commit b328a92

Please sign in to comment.