mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-12-24 05:51:27 +01:00
added docstrings wrap struct into tuple
This commit is contained in:
@@ -62,7 +62,13 @@ void define_Cluster(py::module &m, const std::string &typestr) {
|
||||
|
||||
.def(
|
||||
"max_sum_2x2",
|
||||
&Cluster<Type, ClusterSizeX, ClusterSizeY, CoordType>::max_sum_2x2);
|
||||
[](Cluster<Type, ClusterSizeX, ClusterSizeY, CoordType> &self) {
|
||||
auto max_sum = self.max_sum_2x2();
|
||||
return py::make_tuple(max_sum.sum,
|
||||
static_cast<int>(max_sum.index));
|
||||
},
|
||||
R"(calculates sum of 2x2 subcluster with highest energy and index relative to cluster center 0: top_left, 1: top_right, 2: bottom_left, 3: bottom_right
|
||||
)");
|
||||
}
|
||||
|
||||
template <typename T, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
|
||||
@@ -44,13 +44,16 @@ void define_ClusterVector(py::module &m, const std::string &typestr) {
|
||||
auto *vec = new std::vector<Type>(self.sum());
|
||||
return return_vector(vec);
|
||||
})
|
||||
.def("sum_2x2",
|
||||
.def(
|
||||
"sum_2x2",
|
||||
[](ClusterVector<ClusterType> &self) {
|
||||
auto *vec = new std::vector<Sum_index_pair<Type, corner>>(
|
||||
self.sum_2x2());
|
||||
|
||||
return return_vector(vec);
|
||||
})
|
||||
},
|
||||
R"(calculates sum of 2x2 subcluster with highest energy and index relative to cluster center 0: top_left, 1: top_right, 2: bottom_left, 3: bottom_right
|
||||
)")
|
||||
.def_property_readonly("size", &ClusterVector<ClusterType>::size)
|
||||
.def("item_size", &ClusterVector<ClusterType>::item_size)
|
||||
.def_property_readonly("fmt",
|
||||
|
||||
@@ -86,6 +86,17 @@ def test_calculate_eta():
|
||||
assert eta2[1,0] == 0.5
|
||||
assert eta2[1,1] == 0.4 #2/5
|
||||
|
||||
|
||||
def test_max_sum():
|
||||
"""Max 2x2 Sum"""
|
||||
cluster = _aare.Cluster3x3i(5,5,np.array([1, 1, 1, 2, 3, 1, 2, 2, 1], dtype=np.int32))
|
||||
|
||||
max_sum = cluster.max_sum_2x2()
|
||||
|
||||
assert max_sum[0] == 9
|
||||
assert max_sum[1] == 2
|
||||
|
||||
|
||||
def test_cluster_finder():
|
||||
"""Test ClusterFinder"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user