Skip to content
Open
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
20 changes: 16 additions & 4 deletions qutip_benchmark/benchmarks/bench_linear_algebra.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This file contains the benchmarks that are run the benchmark.py script."""

import pytest
import qutip
import scipy
Expand All @@ -19,21 +20,29 @@
return request.param


@pytest.fixture(params=["dense", "sparse", "tridiag"])
def density_oper(request):
return request.param


@pytest.fixture(params=["dense", "sparse"])
def density(request):
def density_ket(request):
return request.param


@pytest.fixture()
def left_oper(size, density, dtype):
def left_oper(size, density_oper, dtype):
"""Return a random matrix of size `sizexsize'. Density is either 'dense'
or 'sparse' and returns a fully dense or a sparse matrix respectively.
The matrices are Hermitian."""

if density == "sparse":

Check warning on line 39 in qutip_benchmark/benchmarks/bench_linear_algebra.py

View workflow job for this annotation

GitHub Actions / lint-black

F821: undefined name 'density'
res = qutip.rand_herm(size, density=1 / size)
elif density == "dense":

Check warning on line 41 in qutip_benchmark/benchmarks/bench_linear_algebra.py

View workflow job for this annotation

GitHub Actions / lint-black

F821: undefined name 'density'
res = qutip.rand_herm(size, density=1)
elif density == "tridiag":

Check warning on line 43 in qutip_benchmark/benchmarks/bench_linear_algebra.py

View workflow job for this annotation

GitHub Actions / lint-black

F821: undefined name 'density'
a = qutip.destroy(size)
res = a + a.dag() + a * a.dag()

if dtype == "numpy":
return res.full()
Expand All @@ -49,15 +58,18 @@


@pytest.fixture()
def right_oper(size, density, dtype):
def right_oper(size, density_oper, dtype):
"""Return a random matrix of size `sizexsize'. Density is either 'dense'
or 'sparse' and returns a fully dense or a sparse matrix respectively.
The matrices are Hermitian."""

if density == "sparse":

Check warning on line 66 in qutip_benchmark/benchmarks/bench_linear_algebra.py

View workflow job for this annotation

GitHub Actions / lint-black

F821: undefined name 'density'
res = qutip.rand_herm(size, density=1 / size)
elif density == "dense":

Check warning on line 68 in qutip_benchmark/benchmarks/bench_linear_algebra.py

View workflow job for this annotation

GitHub Actions / lint-black

F821: undefined name 'density'
res = qutip.rand_herm(size, density=1)
elif density == "tridiag":

Check warning on line 70 in qutip_benchmark/benchmarks/bench_linear_algebra.py

View workflow job for this annotation

GitHub Actions / lint-black

F821: undefined name 'density'
a = qutip.destroy(size)
res = a + a.dag() + a * a.dag()

if dtype == "numpy":
return res.full()
Expand All @@ -73,8 +85,8 @@


@pytest.fixture()
def right_ket(size, density, dtype):
def right_ket(size, density_ket, dtype):
if density == "sparse":

Check warning on line 89 in qutip_benchmark/benchmarks/bench_linear_algebra.py

View workflow job for this annotation

GitHub Actions / lint-black

F821: undefined name 'density'
res = qutip.rand_ket(size, density=0.3)
else:
res = qutip.rand_ket(size, density=1)
Expand Down
7 changes: 6 additions & 1 deletion qutip_benchmark/benchmarks/bench_qobjevo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This file contains the benchmarks that are run the benchmark.py script."""

import pytest
import qutip
import numpy as np
Expand All @@ -9,7 +10,7 @@ def size(request):
return request.param


@pytest.fixture(params=["dense", "sparse"])
@pytest.fixture(params=["dense", "sparse", "tridiag"])
def density(request):
return request.param

Expand All @@ -35,6 +36,10 @@ def left_QobjEvo(size, density, coeftype):
elif density == "dense":
q_obj = qutip.rand_herm(size, density=1)

elif density == "tridiag":
a = qutip.destroy(size)
q_obj = a + a.dag() + a * a.dag()

# Creating coefficients
tlist = None
if coeftype == "function":
Expand Down
Loading