|
| 1 | +import time |
| 2 | +import cupy as cp |
| 3 | +import numpy as np |
| 4 | +import pytest |
| 5 | + |
| 6 | +from numpy.testing import assert_allclose |
| 7 | +from httomolibgpu.prep.stripe import remove_all_stripe |
| 8 | +from httomolibgpu.prep.normalize import normalize |
| 9 | +from conftest import force_clean_gpu_memory |
| 10 | + |
| 11 | + |
| 12 | +@pytest.mark.parametrize( |
| 13 | + "dataset_fixture, exp_sum, exp_mean, exp_mean_sum, exp_shape", |
| 14 | + [ |
| 15 | + ("i13_dataset1", 32071604.0, 0.208765, 1252.7957, (6001, 10, 2560)), |
| 16 | + ("i13_dataset3", 27234604.0, 0.59093, 3546.1704, (6001, 3, 2560)), |
| 17 | + ], |
| 18 | + ids=["dataset_one", "dataset_three"], |
| 19 | +) |
| 20 | +def test_remove_all_stripe_with_i13_data( |
| 21 | + request, dataset_fixture, exp_sum, exp_mean, exp_mean_sum, exp_shape |
| 22 | +): |
| 23 | + dataset = request.getfixturevalue(dataset_fixture) |
| 24 | + data_normalised = normalize(dataset[0], dataset[2], dataset[3], minus_log=True) |
| 25 | + output = remove_all_stripe(cp.copy(data_normalised)).get() |
| 26 | + |
| 27 | + assert_allclose(np.sum(output), exp_sum, rtol=1e-07, atol=1e-6) |
| 28 | + assert_allclose(np.mean(output), exp_mean, rtol=1e-07, atol=1e-6) |
| 29 | + assert_allclose(np.mean(output, axis=(1, 2)).sum(), exp_mean_sum, rtol=1e-06) |
| 30 | + force_clean_gpu_memory() |
| 31 | + assert output.shape == exp_shape |
| 32 | + assert output.dtype == np.float32 |
| 33 | + assert output.flags.c_contiguous |
0 commit comments