Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 18 additions & 23 deletions .github/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,29 @@ jobs:
needs: pre-commit-ci
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.11", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv & Setup Python
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
# Install a specific version of uv.
python-version: ${{matrix.python-version}}
version: "0.7.12"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
python -m poetry install
- name: Analyze code with pylint
uv venv .venv/
uv pip install -r pyproject.toml --all-extras --all-groups
- name: Check Pre-commits
run: |
python -m pip install pylint
pylint $(git ls-files '*.py')
uv run pre-commit install
uv run pre-commit run -a
continue-on-error: true
- name: Build
run: python -m poetry install
- name: Test and coverage
run: |
python -m pip install pytest pytest-cov
python -m pytest --cov=tn4qa $(git ls-files 'test_*.py')
- name: Mypy type checking
run: |
python -m pip install mypy
mypy tn4qa
- uses: actions/checkout@v4
- name: Run Pytest
run: uv run pytest -n auto

coverage-python:
runs-on: ubuntu-latest
Expand All @@ -73,7 +68,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
cache: "pip"
- name: Install dependencies and tn4qa package
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ target/
profile_default/
ipython_config.py

# Dependencies (covers all below)
*.lock

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
Expand Down
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,3 @@ repos:
rev: v8.21.1
hooks:
- id: gitleaks
- repo: https://github.com/python-poetry/poetry
rev: '1.8.5'
hooks:
- id: poetry-check
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Necessary bug fix to mps to circuit middle out method

## [0.0.7] - 2026-03-19

### Changed
- Python version relaxed and dependencies updated
- Replaced poetry with uv
95 changes: 41 additions & 54 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,67 +1,54 @@
[tool.poetry]
[project]
name = "tn4qa"
version = "0.0.6"
version = "0.0.7"
description = "A Python package to integrate tensor network methods with quantum algorithms."
authors = [
"Angus Mingare <angus.mingare.22@ucl.ac.uk>",
"Isabelle Heuzé <isabelle.heuze.24@ucl.ac.uk>",
{name="Angus Mingare", email="angus.mingare.22@ucl.ac.uk"},
{name="Isabelle Heuzé", email="isabelle.heuze.24@ucl.ac.uk"}
]
license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.11, <3.12"
sparse = "^0.15.4, <0.16"
qiskit = ">=1.3.0, <2"
qiskit-ibm-runtime = ">=0.34.0"
qiskit-aer = ">=0.15.1"
qiskit-algorithms = ">=0.3.1"
cotengra = ">=0.6.2"
kahypar = [
{version = "^1.3.5", platform = "darwin"},
{version = "^1.3.5", platform = "linux"}
requires-python = ">=3.12, <3.15"
dependencies = [
"sparse>=0.15.4, <0.16",
"qiskit>=2.0.0",
"qiskit-ibm-runtime>=0.34.0",
"qiskit-aer>=0.15.1",
"qiskit-algorithms>=0.3.1",
"cotengra>=0.6.2",
"scipy>=1.15.0, <1.16.2",
"numpy>=2.1, <3",
"cotengrust>=0.1.4",
"matplotlib>=3.10.1",
"cached-property>=1.5.2",
"scikit-learn>=1.3.0",
"kahypar>=1.3.6",
"networkx>=3.6.1",
"iqm-client>=22.4",
]
symmer = ">=0.0.9"
scipy = ">=1.15.0, <2"
numpy = ">=2.1, <3"
cotengrust = ">=0.1.4"
matplotlib = ">=3.10.1"
cached-property = ">=1.5.2"
scikit-learn = ">=1.3.0"
iqm-client = { version = ">=29.2.0", optional = true, python = "<3.13" }

[[tool.poetry.source]]
name = "PyPI"
priority = "primary"


[tool.poetry.group.dev.dependencies]
coverage = "^7.6.9"
ipykernel = "^6.29.5"
pyscf = "^2.8.0"
ruff = ">=0.8.2"
black = ">=24.10.0"
isort = ">=5.13.2"
mypy = ">=1.13.0"
poetry = "^1.8.5"
pre-commit = "^4.0.1"
pydocstyle = "^6.3.0"
pytest = "^7.2.2"
sphinx = "^5.3.0"
myst-parser = "^0.18.1"

[tool.poetry.extras]
iqm = ["iqm-client"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project.optional-dependencies]
symmer = [
"symmer>=0.0.10",
]

# Ignore pytest warnings here
[tool.pytest.ini_options]
filterwarnings = [
"ignore:.*The property ``qiskit.dagcircuit.dagcircuit.DAGCircuit.(duration|unit)`` is deprecated as of qiskit 1.3.0.*",
"ignore:.*Couldn't import `kahypar` - skipping from default hyper optimizer and using basic `labels` method instead.*",
[dependency-groups]
dev = [
"coverage>=7.13.1",
"ipykernel>=7.1.0",
"mypy>=1.19.1",
"myst-parser>=5.0.0",
"poetry>=2.3.0",
"pre-commit>=4.5.1",
"pyscf>=2.11.0",
"pytest>=9.0.2",
"pytest-xdist>=3.8.0",
"ruff>=0.14.13",
"sphinx>=9.0.4",
]

[tool.ruff]
Expand Down
5 changes: 3 additions & 2 deletions test/test_mpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,13 @@ def test_contract_sub_mpo():

assert np.allclose(contracted_mpo.to_dense_array(), expected_mpo.to_dense_array())


def test_purity_mpo():
num_sites = 4
target_sites = [1, 3]
qc = QuantumCircuit(2 * num_sites)
for idx in target_sites:
qc.swap(idx-1, num_sites + idx - 1)
qc.swap(idx - 1, num_sites + idx - 1)
qiskit_mpo = MatrixProductOperator.from_qiskit_circuit(qc)
test_purity_mpo = MatrixProductOperator.purity_mpo(num_sites, target_sites)
assert np.allclose(qiskit_mpo.to_dense_array(), test_purity_mpo.to_dense_array())
assert np.allclose(qiskit_mpo.to_dense_array(), test_purity_mpo.to_dense_array())
Loading