Skip to content

Commit 1c07475

Browse files
authored
Modernize ProjectQ (isort, PEP 257 docstrings, drop Python 2 code, more flake8 plugins) and fix phase estimation unit tests (#408)
* Fix tests for the phase estimation decomposition * Fix docstrings according to PEP257 * Modernize code by removing some Python 2 compatibility code * Update CHANGELOG * Add isort to pre-commit-config.yaml and run it on the project * Move common exception classes to their own files * Fix changes from the latest on develop * Update CHANGELOG * Update Python code in documentation folder * Add `meta` repository to pre-commit configuration * Re-indent and cleanup .pre-commit-config.yaml * Add some more flake8 plugins to pre-commit config file - flake8-breakpoint - flake8-comprehensions - flake8-eradicate - flake8-mutable * Fix small bug with drawing using matplotlib * Address review comments * Better comment in docs/conf.py
1 parent 0c44fba commit 1c07475

File tree

215 files changed

+2535
-2600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+2535
-2600
lines changed

.pre-commit-config.yaml

Lines changed: 66 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,77 @@
1212
#
1313
# See https://github.com/pre-commit/pre-commit
1414

15+
---
16+
1517
ci:
16-
skip: [check-manifest]
18+
skip: [check-manifest]
1719

1820
repos:
19-
- repo: https://github.com/pre-commit/pre-commit-hooks
20-
rev: v4.0.1
21-
hooks:
22-
- id: check-added-large-files
23-
- id: check-case-conflict
24-
- id: check-merge-conflict
25-
- id: check-symlinks
26-
- id: check-yaml
27-
- id: check-toml
28-
- id: debug-statements
29-
- id: end-of-file-fixer
30-
- id: mixed-line-ending
31-
- id: trailing-whitespace
32-
- id: fix-encoding-pragma
21+
- repo: meta
22+
hooks:
23+
- id: check-useless-excludes
24+
25+
- repo: https://github.com/pre-commit/pre-commit-hooks
26+
rev: v4.0.1
27+
hooks:
28+
- id: check-added-large-files
29+
- id: check-case-conflict
30+
- id: check-merge-conflict
31+
- id: check-symlinks
32+
- id: check-yaml
33+
- id: check-toml
34+
- id: debug-statements
35+
- id: end-of-file-fixer
36+
- id: mixed-line-ending
37+
- id: trailing-whitespace
38+
- id: fix-encoding-pragma
39+
40+
# Changes tabs to spaces
41+
- repo: https://github.com/Lucas-C/pre-commit-hooks
42+
rev: v1.1.10
43+
hooks:
44+
- id: remove-tabs
3345

34-
# Changes tabs to spaces
35-
- repo: https://github.com/Lucas-C/pre-commit-hooks
36-
rev: v1.1.10
37-
hooks:
38-
- id: remove-tabs
46+
- repo: https://github.com/PyCQA/isort
47+
rev: 5.9.1
48+
hooks:
49+
- id: isort
50+
name: isort (python)
3951

40-
- repo: https://github.com/psf/black
41-
rev: 21.5b1
42-
hooks:
43-
- id: black
44-
language_version: python3
45-
# This is a slow hook, so only run this if --hook-stage manual is passed
46-
stages: [manual]
52+
- repo: https://github.com/psf/black
53+
rev: 21.5b1
54+
hooks:
55+
- id: black
56+
language_version: python3
57+
# This is a slow hook, so only run this if --hook-stage manual is passed
58+
stages: [manual]
4759

48-
- repo: https://gitlab.com/pycqa/flake8
49-
rev: 3.9.2
50-
hooks:
51-
- id: flake8
52-
exclude: ^(docs/.*|tools/.*)$
60+
- repo: https://gitlab.com/PyCQA/flake8
61+
rev: 3.9.2
62+
hooks:
63+
- id: flake8
64+
name: flake8-strict
65+
exclude: ^(.*_test\.py)$
66+
additional_dependencies: [flake8-comprehensions, flake8-breakpoint,
67+
flake8-eradicate, flake8-mutable,
68+
flake8-docstrings]
69+
- id: flake8
70+
name: flake8-test-files
71+
additional_dependencies: [flake8-comprehensions, flake8-breakpoint,
72+
flake8-eradicate, flake8-mutable]
73+
files: ^(.*_test\.py)$
5374

54-
- repo: https://github.com/pre-commit/mirrors-pylint
55-
rev: 'v3.0.0a3'
56-
hooks:
57-
- id: pylint
58-
args: ['--score=n']
59-
# This is a slow hook, so only run this if --hook-stage manual is passed
60-
stages: [manual]
61-
additional_dependencies: ['pybind11>=2.6', 'numpy', 'requests', 'boto3', 'matplotlib', 'networkx']
75+
- repo: https://github.com/pre-commit/mirrors-pylint
76+
rev: 'v3.0.0a3'
77+
hooks:
78+
- id: pylint
79+
args: ['--score=n']
80+
# This is a slow hook, so only run this if --hook-stage manual is passed
81+
stages: [manual]
82+
additional_dependencies: [pybind11>=2.6, numpy, requests, boto3, matplotlib, networkx, sympy]
6283

63-
- repo: https://github.com/mgedmin/check-manifest
64-
rev: "0.46"
65-
hooks:
66-
- id: check-manifest
67-
additional_dependencies: ['setuptools-scm', 'pybind11>=2.6']
84+
- repo: https://github.com/mgedmin/check-manifest
85+
rev: '0.46'
86+
hooks:
87+
- id: check-manifest
88+
additional_dependencies: ['setuptools-scm', 'pybind11>=2.6']

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
### Fixed
1717

1818
- Prevent infinite recursion errors when too many compiler engines are added to the MainEngine
19+
- Error in testing the decomposition for the phase estimation gate
20+
- Make all docstrings PEP257 compliant
1921

2022
### Removed
23+
24+
- Some compatibility code for Python 2.x
25+
2126
### Repository
2227

28+
- Added `isort` to the list of pre-commit hooks
29+
- Added `flake8-docstrings` to the flake8 checks to ensure PEP257 compliance for docstrings
30+
2331
## [0.6.1] - 2021-06-23
2432

2533
### Repository

0 commit comments

Comments
 (0)