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
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
matrix:
runs-on: [ubuntu-latest, windows-latest, macos-latest]
python:
- 3.6
- 3.7
- 3.8
- 3.9
Expand Down Expand Up @@ -64,6 +63,8 @@ jobs:

- name: Prepare env
run: |
python -m pip install -U pip setuptools wheel
cat requirements.txt
python -m pip install -r requirements.txt --prefer-binary
python -m pip install coveralls

Expand Down Expand Up @@ -143,6 +144,8 @@ jobs:
- name: Prepare Python env
run: |
python3 setup.py gen_reqfile --include-extras=test,braket
python3 -m pip install -U pip setuptools wheel
cat requirements.txt
python3 -m pip install -r requirements.txt --prefer-binary

- name: Upgrade pybind11 and flaky
Expand Down Expand Up @@ -188,6 +191,8 @@ jobs:
- name: Prepare Python env
run: |
python3 setup.py gen_reqfile --include-extras=test,braket
python3 -m pip install -U pip setuptools wheel
cat requirements.txt
python3 -m pip install -r requirements.txt --prefer-binary

- name: Upgrade pybind11 and flaky
Expand Down Expand Up @@ -270,6 +275,8 @@ jobs:
- name: Install dependencies
run: |
python3 setup.py gen_reqfile --include-extras=test,braket
python3 -m pip install -U pip setuptools wheel
cat requirements.txt
python3 -m pip install -r requirements.txt --prefer-binary

- name: Build and install package
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repos:
rev: v2.34.0
hooks:
- id: pyupgrade
args: [--py36-plus, --keep-mock]
args: [--py37-plus, --keep-mock]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Support for Python 3.6 and earlier is now deprecated
- Moved package metadata into pyproject.toml

### Repository

- Update `docker/setup-qemu-action` GitHub action to v2
- Fixed CentOS 7 configuration issue
- Added two new pre-commit hooks: `blacken-docs` and `pyupgrade`
- Remove deprecated `setup_requires` field in setup.cfg
- Fixed installation issue with newer versions of `setuptool-scm`and Python¨ 3.6

## [v0.7.3] - 2022-04-27

Expand Down
1 change: 0 additions & 1 deletion examples/shor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
except ImportError:
from fractions import gcd


import projectq.libs.math
import projectq.setups.decompositions
from projectq.backends import ResourceCounter, Simulator
Expand Down
34 changes: 19 additions & 15 deletions projectq/setups/decompositions/arb1qubit2rzandry.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,26 @@ def _find_parameters(matrix): # pylint: disable=too-many-branches,too-many-stat
else:
a = two_a / 2.0 # pylint: disable=invalid-name
two_d = 2.0 * cmath.phase(matrix[0][1]) - 2.0 * cmath.phase(matrix[0][0])
# yapf: disable
possible_d_half = [two_d/4. % (2*math.pi),
(two_d/4.+math.pi/2.) % (2*math.pi),
(two_d/4.+math.pi) % (2*math.pi),
(two_d/4.+3./2.*math.pi) % (2*math.pi)]
two_b = 2. * cmath.phase(matrix[1][0]) - 2. * cmath.phase(matrix[0][0])
possible_b_half = [two_b/4. % (2*math.pi),
(two_b/4.+math.pi/2.) % (2*math.pi),
(two_b/4.+math.pi) % (2*math.pi),
(two_b/4.+3./2.*math.pi) % (2*math.pi)]
possible_d_half = [
two_d / 4.0 % (2 * math.pi),
(two_d / 4.0 + math.pi / 2.0) % (2 * math.pi),
(two_d / 4.0 + math.pi) % (2 * math.pi),
(two_d / 4.0 + 3.0 / 2.0 * math.pi) % (2 * math.pi),
]
two_b = 2.0 * cmath.phase(matrix[1][0]) - 2.0 * cmath.phase(matrix[0][0])
possible_b_half = [
two_b / 4.0 % (2 * math.pi),
(two_b / 4.0 + math.pi / 2.0) % (2 * math.pi),
(two_b / 4.0 + math.pi) % (2 * math.pi),
(two_b / 4.0 + 3.0 / 2.0 * math.pi) % (2 * math.pi),
]
tmp = math.acos(abs(matrix[1][1]))
possible_c_half = [tmp % (2*math.pi),
(tmp+math.pi) % (2*math.pi),
(-1.*tmp) % (2*math.pi),
(-1.*tmp+math.pi) % (2*math.pi)]
# yapf: enable
possible_c_half = [
tmp % (2 * math.pi),
(tmp + math.pi) % (2 * math.pi),
(-1.0 * tmp) % (2 * math.pi),
(-1.0 * tmp + math.pi) % (2 * math.pi),
]
found = False
for b_half, c_half, d_half in itertools.product(possible_b_half, possible_c_half, possible_d_half):
if _test_parameters(matrix, a, b_half, c_half, d_half):
Expand Down
12 changes: 6 additions & 6 deletions projectq/setups/decompositions/carb1qubit2cnotrzandry.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ def _recognize_v(matrix): # pylint: disable=too-many-branches
(two_b / 2.0 + math.pi) % (2 * math.pi),
]
tmp = math.acos(abs(matrix[1][0]))
# yapf: disable
possible_c_half = [tmp % (2*math.pi),
(tmp+math.pi) % (2*math.pi),
(-1.*tmp) % (2*math.pi),
(-1.*tmp+math.pi) % (2*math.pi)]
# yapf: enable
possible_c_half = [
tmp % (2 * math.pi),
(tmp + math.pi) % (2 * math.pi),
(-1.0 * tmp) % (2 * math.pi),
(-1.0 * tmp + math.pi) % (2 * math.pi),
]
for b, c_half in itertools.product(possible_b, possible_c_half): # pylint: disable=invalid-name
if _test_parameters(matrix, a, b, c_half):
return (a, b, c_half)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,9 @@ def _decomp_gates(eng, cmd):
return False


# yapf: disable
@pytest.mark.parametrize("gate_matrix", [[[1, 0], [0, -1]],
[[0, -1j], [1j, 0]]])
@pytest.mark.parametrize("gate_matrix", [[[1, 0], [0, -1]], [[0, -1j], [1j, 0]]])
def test_recognize_v(gate_matrix):
assert carb1q._recognize_v(gate_matrix)
# yapf: enable


@pytest.mark.parametrize("gate_matrix", arb1q_t.create_test_matrices())
Expand Down
75 changes: 66 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,81 @@
[build-system]
requires = ["setuptools>=42", "wheel", "pybind11>=2",
"setuptools_scm[toml]<7;python_version<'3.7'",
"setuptools_scm[toml]>6;python_version>='3.7'"]
requires = [
'setuptools>=61;python_version>="3.7"',
'setuptools>=59;python_version<"3.7"',
'wheel',
'pybind11>=2',
'setuptools_scm[toml]>6;python_version>="3.7"'
]
build-backend = "setuptools.build_meta"

[project]
name = 'projectq'
authors = [
{name = 'ProjectQ', email = 'info@projectq.ch'}
]
description = 'ProjectQ - An open source software framework for quantum computing'
requires-python = '>= 3.7'
license = {text= 'Apache License Version 2.0'}
readme = 'README.rst'
classifiers = [
'License :: OSI Approved :: Apache Software License',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
]
dynamic = ["version"]

dependencies = [
'matplotlib >= 2.2.3',
'networkx >= 2',
'numpy',
'requests',
'scipy'
]

[project.urls]
'Homepage' = 'http://www.projectq.ch'
'Documentation' = 'https://projectq.readthedocs.io/en/latest/'
'Issue Tracker' = 'https://github.com/ProjectQ-Framework/ProjectQ/'

[project.optional-dependencies]

braket = [
'boto3'
]

revkit = [
'revkit == 3.0a2.dev2',
'dormouse'
]

test = [
'flaky',
'mock',
'pytest >= 6.0',
'pytest-cov',
'pytest-mock'
]

docs = [
'sphinx',
'sphinx_rtd_theme'
]

# ==============================================================================

[tool.black]

line-length = 120
target-version = ['py36','py37','py38']
target-version = ['py37','py38','py39','py310']
skip-string-normalization = true


[tool.check-manifest]
ignore = [
ignore = [
'PKG-INFO',
'*.egg-info',
'*.egg-info/*',
Expand Down Expand Up @@ -112,10 +173,6 @@ write_to = 'VERSION.txt'
write_to_template = '{version}'
local_scheme = 'no-local-version'

[tool.yapf]

column_limit = 120

[tool.cibuildwheel]

archs = ['auto64']
Expand Down
55 changes: 1 addition & 54 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,73 +1,20 @@
[metadata]

name = projectq
version = file:VERSION.txt
url = http://www.projectq.ch
author = ProjectQ
author_email = info@projectq.ch
project_urls =
Documentation = https://projectq.readthedocs.io/en/latest/
Issue Tracker = https://github.com/ProjectQ-Framework/ProjectQ/
license = Apache License Version 2.0
license_file = LICENSE
description = ProjectQ - An open source software framework for quantum computing
long_description = file:README.rst
long_description_content_type = text/x-rst; charset=UTF-8
home_page = http://www.projectq.ch
requires_dist = setuptools
classifier =
License :: OSI Approved :: Apache Software License
Topic :: Software Development :: Libraries :: Python Modules
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]

zip_safe = False
packages = find:
python_requires = >= 3
install_requires =
matplotlib >= 2.2.3
networkx >= 2
numpy
requests
scipy

[options.extras_require]

braket = boto3
revkit =
revkit == 3.0a2.dev2
dormouse
test =
flaky
mock
pytest >= 6.0
pytest-cov
pytest-mock

docs =
sphinx
sphinx_rtd_theme


# ==============================================================================

[flake8]

max-line-length = 120
ignore = E203,W503,E800
exclude =
.git,
__pycache__,
build,
dist,
__init__.py
docstring-quotes = """
eradicate-whitelist = # yapf: disable# yapf: enable

# ==============================================================================
Loading