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
16 changes: 15 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,18 @@ jobs:
- name: Install black
run: pip install black
- name: Run black
run: black --check --diff .
run: black --check --diff .
pytest-ubuntu:
name: Tests (Ubuntu)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v5
with:
python-version: '3.13'
architecture: 'x64'
cache: 'pip'
- name: Install requirements
run: pip install .[dev]
- name: Run tests
run: pytest qmath
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ developing algorithms for fault-tolerant quantum computers.

### Setup

Clone repository into `/home/coder/projects` in PsiQDE instance. Then:

```
cd /home/coder/projects/qmath
git clone https://github.com/fedimser/qmath.git
cd qmath
python -m pip install -e .[dev] # Install dependencies.
pre-commit install # Install pre-commit hooks.
pytest -m smoke # Run tests.
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ classifiers = [

# https://peps.python.org/pep-0508/
dependencies = [
"numpy"
"numpy",
"psiqdk==2.0.0"
]

[project.optional-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions qmath/func/common_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_re_abs():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=1)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=1)
for n, radix in [(2, 0), (2, 1), (5, 0), (5, 5), (8, 8), (10, 5)]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_atol=0.5)
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_atol=1.0)


@pytest.mark.re
Expand All @@ -27,7 +27,7 @@ def test_re_add():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=2)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=2)
for n, radix in [(2, 0), (2, 1), (5, 0), (5, 5), (8, 8), (10, 5), (16, 16)]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix})
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.02)


@pytest.mark.re
Expand All @@ -46,7 +46,7 @@ def test_re_subtract():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=2)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=2)
for n, radix in [(10, 0), (10, 5)]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix})
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.01)


@pytest.mark.re
Expand All @@ -55,4 +55,4 @@ def test_re_multiply_add():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=3)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=3)
for n, radix in [(4, 1), (4, 2), (4, 3), (5, 1), (5, 4), (10, 1), (10, 9), (16, 8)]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.001)
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.02)
2 changes: 1 addition & 1 deletion qmath/func/fbe_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def test_re_CosFbe():
re_symbolic = re_symbolic_CosFbe()
re_numeric = re_numeric_CosFbe
for n, m in [(2, 2), (3, 4), (5, 8), (10, 10), (15, 10), (10, 16)]:
verify_re(re_symbolic, re_numeric, {"n": n, "m": m})
verify_re(re_symbolic, re_numeric, {"n": n, "m": m}, av_rtol=0.011)
4 changes: 2 additions & 2 deletions qmath/func/inv_sqrt_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_re_newton_iteration():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=3)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=3)
for n, radix in [(10, 5)]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.001)
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.012)


@pytest.mark.re
Expand All @@ -31,4 +31,4 @@ def test_re_inv_sqrt(num_iterations: int):
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=1, qubits_factor=20)
test_cases = [(6, 2), (6, 3), (6, 4), (10, 3), (10, 5), (10, 8), (20, 7), (20, 12)]
for n, radix in test_cases:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.001)
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.012)
4 changes: 2 additions & 2 deletions qmath/func/sqrt_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_re_sqrt_fast(half_arg: bool):
op = Sqrt(half_arg=half_arg)
re_symbolic = re_symbolic_fixed_point(op)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn)
verify_re(re_symbolic, re_numeric, {"n": 5, "radix": 1})
verify_re(re_symbolic, re_numeric, {"n": 5, "radix": 1}, av_rtol=0.013)


@pytest.mark.re
Expand All @@ -21,4 +21,4 @@ def test_re_sqrt(half_arg: bool):
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn)
for n in [5, 6, 7, 20, 21]:
for radix in [0, 1, 2, 5]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix})
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.013)
2 changes: 1 addition & 1 deletion qmath/func/square_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_re_square():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=2)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=2)
for n, radix in [(10, 1), (10, 5), (10, 9)]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.001)
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.009)


@pytest.mark.re
Expand Down
2 changes: 1 addition & 1 deletion qmath/poly/horner_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def test_re_horner_scheme():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=1)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=1)
for n, radix in [(10, 5)]:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.001)
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.01)
4 changes: 2 additions & 2 deletions qmath/poly/piecewise_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_re_ppa():
op = EvalFunctionPPA(lambda x: np.cos(x), interval=[-1, 1], degree=2, error_tol=1e-3)
re_symbolic = re_symbolic_fixed_point(op, n_inputs=1)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=1)
verify_re(re_symbolic, re_numeric, {"n": 10, "radix": 6}, av_rtol=0.015, elbows_rtol=0.01)
verify_re(re_symbolic, re_numeric, {"n": 10, "radix": 6}, av_rtol=0.025, elbows_rtol=0.01)


@pytest.mark.re
Expand All @@ -25,4 +25,4 @@ def test_re_ppa_slow():
re_symbolic = re_symbolic_fixed_point(op, n_inputs=1)
re_numeric = lambda assgn: re_numeric_fixed_point(op, assgn, n_inputs=1)
for n, radix in params:
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.015, elbows_rtol=0.01)
verify_re(re_symbolic, re_numeric, {"n": n, "radix": radix}, av_rtol=0.025, elbows_rtol=0.01)
2 changes: 1 addition & 1 deletion qmath/uint_arith/div/dividers_re_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def test_re_tmvh_divider(restoring: bool):
re_symbolic = re_symbolic_divider(op)
re_numeric = lambda assgn: re_numeric_divider(op, assgn)
for na, nb in [(2, 2), (5, 3), (8, 7), (10, 10)]:
verify_re(re_symbolic, re_numeric, {"na": na, "nb": nb})
verify_re(re_symbolic, re_numeric, {"na": na, "nb": nb}, av_rtol=0.02)
Loading