Skip to content

Commit 624f482

Browse files
authored
360 to 180 weigths to floats + a test (#138)
* turning weights into floats and adding a test with real data * turning weights into floats2
1 parent 1c94b84 commit 624f482

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

httomolibgpu/misc/morph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ def __sino_360_to_180(
8383
out = cp.empty((n, dy, 2 * dz - overlap), dtype=data.dtype)
8484

8585
if rotation == "left":
86-
weights = cp.linspace(0, 1.0, overlap)
86+
weights = cp.linspace(0, 1.0, overlap, dtype=cp.float32)
8787
out[:, :, -dz + overlap :] = data[:n, :, overlap:]
8888
out[:, :, : dz - overlap] = data[n : 2 * n, :, overlap:][:, :, ::-1]
8989
out[:, :, dz - overlap : dz] = (
9090
weights * data[:n, :, :overlap]
9191
+ (weights * data[n : 2 * n, :, :overlap])[:, :, ::-1]
9292
)
9393
elif rotation == "right":
94-
weights = cp.linspace(1.0, 0, overlap)
94+
weights = cp.linspace(1.0, 0, overlap, dtype=cp.float32)
9595
out[:, :, : dz - overlap] = data[:n, :, :-overlap]
9696
out[:, :, -dz + overlap :] = data[n : 2 * n, :, :-overlap][:, :, ::-1]
9797
out[:, :, dz - overlap : dz] = (

tests/test_misc/test_morph.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
from httomolibgpu.misc.morph import sino_360_to_180, data_resampler
88

99

10+
11+
@pytest.mark.parametrize("rotation", ["left", "right"])
12+
def test_sino_360_to_180_realdata(ensure_clean_memory, sino3600, rotation):
13+
shape_new = (3601, 3, 2560)
14+
data3d = cp.zeros(shape_new, dtype=np.float32)
15+
data3d[:,0,:] = sino3600
16+
data3d[:,1,:] = sino3600
17+
data3d[:,2,:] = sino3600
18+
19+
sino_360_to_180(data3d, overlap=900, rotation=rotation)
20+
21+
assert data3d.shape == shape_new
22+
assert data3d.dtype == np.float32
23+
assert data3d.flags.c_contiguous
24+
1025
@pytest.mark.parametrize(
1126
"overlap, rotation",
1227
[

0 commit comments

Comments
 (0)