added test for apply_remap
Build on RHEL9 / build (push) Successful in 2m40s
Build on RHEL8 / build (push) Successful in 3m24s
Run tests using data on local RHEL8 / build (push) Failing after 4m22s

This commit is contained in:
2026-09-08 12:34:28 +02:00
parent f8eeca2f7a
commit b73f3b723f
3 changed files with 36 additions and 12 deletions
+14 -6
View File
@@ -177,7 +177,7 @@ void define_RemapAlgorithm(py::module &m) {
// cant use np.take or have to mask -1 indices
m.def(
"ApplyRemap",
"apply_remap",
[](py::array input,
py::array_t<ssize_t, py::array::c_style | py::array::forcecast>
order_map,
@@ -191,8 +191,11 @@ void define_RemapAlgorithm(py::module &m) {
throw std::runtime_error("Input and output arrays must be 2D");
}
auto i_dtype = input.dtype();
auto o_dtype = output.dtype();
if (!input.dtype().is(py::dtype::of<uint16_t>())) {
throw std::runtime_error("Apply remap only supports input "
"arrays of type uint16_t"); // jungfrau
// frames
}
if (!input.dtype().is(output.dtype())) {
throw std::runtime_error(
@@ -202,13 +205,18 @@ void define_RemapAlgorithm(py::module &m) {
auto input_array =
py::array_t<uint16_t, py::array::c_style |
py::array::forcecast>::ensure(input);
if (!input_array) {
throw std::runtime_error("conversion failed");
}
auto output_array =
py::array_t<uint16_t, py::array::c_style |
py::array::forcecast>::ensure(output);
aare::remap::algo::ApplyRemap(
make_view_2d(input_array), // TODO expecting uint16_t for now
make_view_2d(order_map), make_view_2d(output_array));
aare::remap::algo::ApplyRemap(make_view_2d(input_array),
make_view_2d(order_map),
make_view_2d(output_array));
},
py::arg("input").noconvert(), py::arg("order_map").noconvert(),
py::arg("output").noconvert(),
+22 -3
View File
@@ -71,18 +71,37 @@ def test_predefinedRemap():
user_roi = strixelremap.InclusiveROI(strixelremap.Chip1.placement_on_module.xmin + 5, strixelremap.Chip1.placement_on_module.xmin + 9, strixelremap.Chip1.placement_on_module.ymin + 5, strixelremap.Chip1.placement_on_module.ymin + 7)
strixelpixelmap = strixelremap.jungfrau_tew_singlechip_25um_strixel_map(user_roi = user_roi, placement = strixelremap.Chip1)
print(strixelpixelmap.map)
assert strixelpixelmap.map.shape == (9, 2)
assert np.array_equal(strixelpixelmap.map, np.array([[-1, 2], [0, 3], [1, 4], [-1, 7], [5,8], [6,9], [-1,12], [10,13], [11,14]]))
input_data = np.array([[1,2,3,4,5],[1,2,3,4,5], [1,2,3,4,5]]).astype(np.uint16)
order_map = strixelpixelmap.map
output = np.empty(order_map.shape, dtype=input_data.dtype)
strixelremap.apply_remap(input_data, order_map, output)
assert np.array_equal(output, np.array([[0, 3], [1,4], [2,5], [0, 3], [1,4], [2,5], [0, 3], [1,4], [2,5]]))
def test_apply_remap():
""" Apply remap throws upon invalid input data type """
strixelpixelmap = strixelremap.jungfrau_ilgad_singlechip_25um_strixel_map(user_roi = strixelremap.Chip1.placement_on_module, placement = strixelremap.Chip1)
# test apply remap
order_map = strixelpixelmap.map
user_roi_height = strixelremap.Chip1.placement_on_module.height
user_roi_width = strixelremap.Chip1.placement_on_module.width
data = np.random.rand(user_roi_height, user_roi_width).astype(np.float64)
output = np.empty(order_map.shape, dtype=data.dtype)
with pytest.raises(RuntimeError):
strixelremap.apply_remap(data, order_map, output)
# Documenation, Example