Skip to content

Commit d9aa866

Browse files
authored
Improvements for release (#1)
* πŸ“¦ created kakuro problem class * 🚧 * 🚧 * ✨ added TSP * πŸ› added file for debugging purposes * 🚨 * ✨ added precommit hook and applied it * 🚧 WIP * πŸ’‘ improved readme * ❇️ added linter workflow * πŸ‘· added badge * βœ… added tests for kakuro * 🎨 code improvements * 🎨 code improvements * βœ… added tests and example notebook for TSP * 🎨 improved tsp code * 🎨 improved kakuro code structure * 🚧 progress * ✨ improved kakuro * ✨ improved csp/kakuro * 🎨 removed unnecessary prints * 🎨 applied precommit hooks * πŸ”₯ removed old files * πŸ”§ adjusted precommit hook config * ✨ improved tsp * 🚧 * πŸ’‘ improved documentation * πŸ™ˆ added folder * ✨ improved code * ✨ improved tsp * πŸ’‘ improved TSP code docu * πŸ’‘ improved CSP code docu * πŸ’‘ improved CSP code docu * πŸ’‘ improved code docu * πŸ’‘ improved code docu * ✨ implemented alternative for unitary creation * πŸ‘· added coverage workflow * πŸ‘· added coverage workflow * πŸ’‘ code docu * πŸ‘· adjusted coverage * πŸ‘· adjusted coverage * πŸ‘· adjusted coverage * πŸ‘· adjusted coverage * πŸ‘· adjusted coverage * πŸ‘· adjusted coverage * πŸ“¦ added setup.py and pyproject.toml * πŸ‘· adjusted coverage * πŸ“¦ adjusted imports * πŸ“¦ adjusted imports * ♻️ went back to original method * πŸ“¦ added dependencies * πŸ“¦ added dependencies * πŸ“¦ added badge * 🎨 removed print statement * πŸ’‘ adjusted readme * πŸ’‘ adjusted readme * πŸ’‘ adjusted readme * πŸ’‘ adjusted readme * πŸ’‘ add screenshot for readme * πŸ’‘ improved readme * 🎨 changed example * ♻️ renamed method * ♻️ renamed files * πŸ”₯ removed old and not used file * 🎨 adjusted and applied precommit hooks * 🎨 applied precommit hooks * πŸ’‘ improved minor issues * πŸ› fixed copy paste error * πŸ‘· added workflow to package and publish to pypi
1 parent 43cc51c commit d9aa866

25 files changed

+1632
-2599
lines changed

β€Ž.flake8β€Ž

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[flake8]
2+
extend-select = B9
3+
extend-ignore = E203, E231, E501, E722, W503, B950, B014, W504, E123, E126, E226, E121
4+
per-file-ignores = __init__.py:F401
5+
max-line-length = 120
6+
show-source = true
7+
exclude =
8+
.git,
9+
.idea,
10+
.eggs,
11+
__pycache__,
12+
.tox,
13+
docs/source/conf.py,
14+
build,
15+
.nox,
16+
venv,
17+
.venv
18+
application-import-names = mqt.problemsolver

β€Ž.github/codecov.ymlβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
range: 60..90
3+
precision: 1
4+
status:
5+
project:
6+
default:
7+
threshold: 0.5%
8+
patch:
9+
default:
10+
threshold: 1%
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CodeCov
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
run:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
- name: Setup Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.9"
19+
- name: Install MQT ProblemSolver
20+
run: pip install .[coverage]
21+
- name: Generate Report
22+
run: pytest -v --cov=./ --cov-report=xml
23+
# - name: Upload coverage to Codecov
24+
# uses: codecov/codecov-action@v3
25+
# with:
26+
# fail_ci_if_error: true

β€Ž.github/workflows/deploy.ymlβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Deploy to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches: [main, master]
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
build_wheel:
13+
name: Build wheel
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- uses: actions/setup-python@v4
20+
name: Install Python
21+
with:
22+
python-version: "3.9"
23+
- name: Install dependencies
24+
run: python -m pip install build
25+
- name: Build wheel
26+
run: python -m build --wheel
27+
- name: Install wheel
28+
run: python -m pip install --verbose dist/*.whl
29+
- uses: actions/upload-artifact@v3
30+
with:
31+
path: dist/*.whl
32+
33+
build_sdist:
34+
name: Build src distribution
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0
40+
- uses: actions/setup-python@v4
41+
name: Install Python
42+
with:
43+
python-version: "3.9"
44+
- name: Install dependencies
45+
run: python -m pip install build
46+
- name: Build sdist
47+
run: python -m build --sdist
48+
- name: Install sdist
49+
run: python -m pip install --verbose dist/*.tar.gz
50+
- uses: actions/upload-artifact@v3
51+
with:
52+
path: dist/*.tar.gz
53+
54+
upload_pypi:
55+
needs: [build_wheel, build_sdist]
56+
runs-on: ubuntu-latest
57+
if: github.event_name == 'release' && github.event.action == 'published'
58+
steps:
59+
- uses: actions/download-artifact@v3
60+
with:
61+
name: artifact
62+
path: dist
63+
- uses: pypa/gh-action-pypi-publish@master
64+
with:
65+
user: __token__
66+
password: ${{ secrets.pypi_password }}
67+
skip_existing: true
68+
verbose: true

β€Ž.github/workflows/linter.ymlβ€Ž

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
Black:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-python@v4
11+
with:
12+
python-version: "3.9"
13+
- name: Black
14+
uses: psf/black@stable

β€Ž.gitignoreβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
./idea
2+
.DS_Store
3+
24
# Created by https://www.toptal.com/developers/gitignore/api/pycharm+all,python,jupyternotebooks
35
# Edit at https://www.toptal.com/developers/gitignore?templates=pycharm+all,python,jupyternotebooks
46

@@ -263,4 +265,4 @@ cython_debug/
263265
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
264266
#.idea/
265267

266-
# End of https://www.toptal.com/developers/gitignore/api/pycharm+all,python,jupyternotebooks
268+
# End of https://www.toptal.com/developers/gitignore/api/pycharm+all,python,jupyternotebooks

β€Ž.pre-commit-config.yamlβ€Ž

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# To run all pre-commit checks, use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# To install pre-commit hooks that run every time you commit:
6+
#
7+
# pre-commit install
8+
#
9+
10+
ci:
11+
autoupdate_commit_msg: "⬆️πŸͺ update pre-commit hooks"
12+
autofix_commit_msg: "🎨 pre-commit fixes"
13+
14+
repos:
15+
# Standard hooks
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: "v4.3.0"
18+
hooks:
19+
- id: check-added-large-files
20+
- id: check-case-conflict
21+
- id: check-docstring-first
22+
- id: check-merge-conflict
23+
- id: check-symlinks
24+
- id: check-toml
25+
- id: check-yaml
26+
- id: debug-statements
27+
- id: end-of-file-fixer
28+
- id: mixed-line-ending
29+
- id: requirements-txt-fixer
30+
- id: trailing-whitespace
31+
32+
# Handling unwanted unicode characters
33+
- repo: https://github.com/sirosen/texthooks
34+
rev: "0.4.0"
35+
hooks:
36+
- id: fix-ligatures
37+
- id: fix-smartquotes
38+
39+
# Sort includes
40+
- repo: https://github.com/pycqa/isort
41+
rev: 5.10.1
42+
hooks:
43+
- id: isort
44+
args: ["--profile", "black", "--filter-files"]
45+
46+
# Upgrade old Python syntax
47+
- repo: https://github.com/asottile/pyupgrade
48+
rev: "v2.37.3"
49+
hooks:
50+
- id: pyupgrade
51+
args: ["--py37-plus"]
52+
53+
# Run code formatting with Black
54+
- repo: https://github.com/psf/black
55+
rev: "22.8.0" # Keep in sync with blacken-docs
56+
hooks:
57+
- id: black
58+
59+
# Also run Black on examples in the documentation
60+
- repo: https://github.com/asottile/blacken-docs
61+
rev: "v1.12.1"
62+
hooks:
63+
- id: blacken-docs
64+
additional_dependencies:
65+
- black==22.8.0 # keep in sync with black hook
66+
67+
# Check for common mistakes
68+
- repo: https://github.com/pre-commit/pygrep-hooks
69+
rev: "v1.9.0"
70+
hooks:
71+
- id: python-check-blanket-noqa
72+
- id: python-check-blanket-type-ignore
73+
- id: python-no-log-warn
74+
- id: python-no-eval
75+
- id: python-use-type-annotations
76+
- id: rst-backticks
77+
- id: rst-directive-colons
78+
- id: rst-inline-touching-normal
79+
80+
# Run Flake8 checks
81+
- repo: https://github.com/PyCQA/flake8
82+
rev: "5.0.4"
83+
hooks:
84+
- id: flake8
85+
additional_dependencies:
86+
- flake8-bugbear
87+
- flake8-comprehensions
88+
- flake8-future-annotations
89+
- flake8-new-union-types
90+
- flake8-simplify
91+
- flake8-2020
92+
93+
# Check for spelling
94+
- repo: https://github.com/codespell-project/codespell
95+
rev: "v2.2.1"
96+
hooks:
97+
- id: codespell
98+
args: ["-L", "wille,linz"]
99+
exclude: >
100+
(?x)^(
101+
.*\.ipynb
102+
)$
103+
104+
# Format configuration files with prettier
105+
- repo: https://github.com/pre-commit/mirrors-prettier
106+
rev: "v3.0.0-alpha.0"
107+
hooks:
108+
- id: prettier
109+
types_or: [yaml, markdown, html, css, javascript, json]

β€ŽREADME.mdβ€Ž

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
1-
# MQT ProblemSolver
2-
Proof of concept implementations for instances of two problem classes.
1+
[![Lint](https://github.com/nquetschlich/MQTProblemSolver/actions/workflows/linter.yml/badge.svg)](https://github.com/nquetschlich/MQTProblemSolver/actions/workflows/linter.yml)
2+
[![CodeCov](https://github.com/nquetschlich/MQTProblemSolver/actions/workflows/coverage.yml/badge.svg)](https://github.com/nquetschlich/MQTProblemSolver/actions/workflows/coverage.yml)
3+
4+
# MQT ProblemSolver
5+
6+
MQT ProblemSolver is a framework to utilize quantum computing as a technology for users with little to no
7+
quantum computing knowledge.
8+
All necessary quantum parts are embedded by domain experts while the interfaces provided are similar to the ones
9+
classical solver provide:
10+
11+
<p align="center">
12+
<img src="img/framework.png" height=300px>
13+
</p>
14+
15+
When provided with a problem description, MQT ProblemSolver offers a selection of implemented quantum algorithms.
16+
The user just has to chose one and all further (quantum) calculation steps are encapsulated within MQT ProblemSolver.
17+
After the calculation finished, the respective solution is returned - again in the same format as classical
18+
solvers use.
19+
20+
In the current implementation, two case studies are conducted:
21+
22+
1. A SAT Problem: Constraint Satisfaction Problem
23+
2. A Graph-based Optimization Problem: Travelling Salesman Problem
24+
25+
# A SAT Problem: Constraint Satisfaction Problem
26+
27+
This exemplary implementation can be found in the [CSP_example.ipynb](src/mqt/problemsolver/csp_example.ipynb) Jupyter notebook.
28+
Here, the solution to a Kakuro riddle with a 2x2 grid can be solved for arbitrary sums `s0` to `s3`:
29+
30+
<p align="center">
31+
<img src="img/kakuro.png" height=100px>
32+
</p>
33+
34+
MQT ProblemSolver will return valid values to `a`, `b`, `c`, and `d` if a solution exists.
35+
36+
# A Graph-based Optimization Problem: Travelling Salesman Problem
37+
38+
This exemplary implementation can be found in the [TSP_example.ipynb](src/mqt/problemsolver/tsp_example.ipynb) Jupyter notebook.
39+
Here, the solution to a Travelling Salesman Problem with 4 cities can be solved for arbitrary distances `dist_1_2` to `dist_3_4`between the cities.
40+
41+
<p align="center">
42+
<img src="img/tsp.png" height=200px>
43+
</p>
44+
45+
MQT ProblemSolver will return the shortest path visiting all cities.
46+
47+
# Repository Structure
48+
49+
```
50+
.
51+
β”œβ”€β”€ src
52+
β”‚ └── mqt
53+
β”‚ └── problemsolver
54+
β”‚ └── csp.py
55+
β”‚ └── csp_example.ipynb
56+
β”‚ └── tsp.py
57+
β”‚ └── tsp_example.ipynb
58+
└── tests
59+
└── ...
60+
```

β€Žimg/framework.pngβ€Ž

428 KB
Loading

β€Žimg/kakuro.pngβ€Ž

10.6 KB
Loading

0 commit comments

Comments
Β (0)