Skip to content

Commit

Permalink
adding pytest to pyproject
Browse files Browse the repository at this point in the history
  • Loading branch information
dkazanc committed Jun 10, 2024
1 parent b6c2757 commit 4aaba2a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ include = ["ccpi", "ccpi.*"]
[project]
version = "24.0.1"
name = "ccpi-regulariser"
dependencies = ["numpy"]
dependencies = [
"numpy",
"pillow",
"pytest"
]
[project.optional-dependencies]
gpu = ["cupy"]
49 changes: 49 additions & 0 deletions test/test_2d_cpu_vs_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,55 @@ def test_PD_TV_CPU_vs_GPU(host_pepper_im, host_pepper_im_noise):
assert pd_gpu.dtype == np.float32


def test_PD_TV_CPU_vs_GPU_nonsqure(
host_pepper_im_nonsquare, host_pepper_im_noise_nonsquare
):
pars = {
"algorithm": PD_TV,
"input": host_pepper_im_noise_nonsquare,
"regularisation_parameter": 0.02,
"number_of_iterations": 1500,
"tolerance_constant": 0.0,
"methodTV": 0,
"nonneg": 0,
"lipschitz_const": 8,
}

print("#############PD TV CPU####################")
pd_cpu = PD_TV(
pars["input"],
pars["regularisation_parameter"],
pars["number_of_iterations"],
pars["tolerance_constant"],
pars["lipschitz_const"],
pars["methodTV"],
pars["nonneg"],
device="cpu",
)
rms_cpu = rmse(host_pepper_im_nonsquare, pd_cpu)
print("##############PD TV GPU##################")
pd_gpu = PD_TV(
pars["input"],
pars["regularisation_parameter"],
pars["number_of_iterations"],
pars["tolerance_constant"],
pars["lipschitz_const"],
pars["methodTV"],
pars["nonneg"],
device="gpu",
)
rms_gpu = rmse(host_pepper_im_nonsquare, pd_gpu)

print("--------Compare the results--------")
eps = 1e-5
assert_allclose(rms_cpu, rms_gpu, rtol=eps)
assert_allclose(np.max(pd_cpu), np.max(pd_gpu), rtol=eps)
assert rms_cpu > 0.0
assert rms_gpu > 0.0
assert pd_cpu.dtype == np.float32
assert pd_gpu.dtype == np.float32


# def test_PD_TV_CPU_vs_GPU(self):
# u0, u_ref, Im = self._initiate_data()

Expand Down

0 comments on commit 4aaba2a

Please sign in to comment.