-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from qognitive/feature/restructure-project-for-…
…python Feature/restructure project for python
- Loading branch information
Showing
34 changed files
with
323 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# noqa: D100 | ||
import os | ||
import sys | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,10 +72,12 @@ __pycache__ | |
*.xwm | ||
|
||
# Misc | ||
.venv | ||
.vscode | ||
.coverage | ||
*.zip | ||
*_package | ||
venv | ||
logs | ||
scratch | ||
notes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.PHONY: build | ||
build: | ||
cmake -B build | ||
cmake --build build --parallel | ||
# TODO in general python build should internally trigger cmake, but for now | ||
# let's keep cmake lines here as we don't have any python build process yet | ||
python -m pip cache purge | ||
python -m pip install --upgrade pip | ||
python -m pip install ".[dev]" | ||
python -m build . | ||
|
||
.PHONY: tests | ||
tests: | ||
ctest --test-dir build | ||
python -m pytest fast_pauli/py/tests | ||
python -m pytest tests | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf build dist | ||
|
||
lint: | ||
pre-commit run --all-files -- ruff | ||
pre-commit run --all-files -- mypy | ||
pre-commit run --all-files -- codespell | ||
|
||
# run with make -i to ignore errors and run all three formatters | ||
format: | ||
pre-commit run --all-files -- ruff-format | ||
pre-commit run --all-files -- yamlfmt | ||
pre-commit run --all-files -- trailing-whitespace | ||
|
||
.PHONY: pre-commit-setup | ||
pre-commit-setup: | ||
pre-commit install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Benchmarking module to compare C++ implementation against numpy.""" |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""pypauli module provides implementations to benchmark and test c++ library.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Separate file with helper functions for Pauli matrices.""" | ||
|
||
import numpy as np | ||
|
||
|
||
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. | ||
This function returns a dictionary with keys representing the matrix names | ||
("I", "X", "Y", "Z", 0, 1, 2, 3) and values representing the corresponding matrix. | ||
Returns | ||
------- | ||
dict: A dictionary containing the Pauli matrices. | ||
""" | ||
s0 = np.array([[1, 0], [0, 1]], dtype=np.complex128) | ||
s1 = np.array([[0, 1], [1, 0]], dtype=np.complex128) | ||
s2 = np.array([[0, -1j], [1j, 0]], dtype=np.complex128) | ||
s3 = np.array([[1, 0], [0, -1]], dtype=np.complex128) | ||
return {"I": s0, "X": s1, "Y": s2, "Z": s3, 0: s0, 1: s1, 2: s2, 3: s3} | ||
|
||
|
||
def naive_pauli_converter(string: str) -> np.ndarray: | ||
"""Convert Pauli string representation into corresponding dense matrix. | ||
Parameters | ||
---------- | ||
string : str | ||
The string representation of Pauli string. | ||
Returns | ||
------- | ||
np.ndarray | ||
The matrix representation of the Pauli string. | ||
""" | ||
paulis = pauli_matrices() | ||
matrix = paulis[string[-1]] | ||
for p in reversed(string[:-1]): | ||
matrix = np.kron(paulis[p], matrix) | ||
return matrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Unit tests for pypauli module.""" |
Oops, something went wrong.