Skip to content

Commit 6a44f67

Browse files
committed
[Python] Minor changes and returning a ref instead of raw ptr
1 parent d7cc1b0 commit 6a44f67

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

python/SiPMHitPy.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ void SiPMHitPy(py::module& m) {
1111
sipmhit.def("time", &SiPMHit::time)
1212
.def("row", &SiPMHit::row)
1313
.def("col", &SiPMHit::col)
14-
.def("amplitude", static_cast<double (SiPMHit::*)() const noexcept>(&SiPMHit::amplitude))
14+
.def("amplitude", static_cast<float (SiPMHit::*)() const noexcept>(&SiPMHit::amplitude))
1515
.def("hitType", &SiPMHit::hitType)
16+
.def("parent", &SiPMHit::parent, py::return_value_policy::reference)
1617
.def("__repr__", &SiPMHit::toString)
17-
.def("__copy__", [](const SiPMHit& self) { return SiPMHit(self); })
1818
.def("__deepcopy__", [](const SiPMHit& self, py::dict) { return SiPMHit(self); });
1919

2020
py::enum_<SiPMHit::HitType>(sipmhit, "HitType")

python/SiPMPropertiesPy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void SiPMPropertiesPy(py::module& m) {
5656
.def("setSnr", &SiPMProperties::setSnr)
5757
.def("setTauApFastComponent", &SiPMProperties::setTauApFastComponent)
5858
.def("setTauApSlowComponent", &SiPMProperties::setTauApSlowComponent)
59-
.def("setTauApSlowFraction", &SiPMProperties::setTauApSlowFraction)
59+
.def("setApSlowFraction", &SiPMProperties::setApSlowFraction)
6060
.def("setCcgv", &SiPMProperties::setCcgv)
6161
.def("setPde", &SiPMProperties::setPde)
6262
.def("setDcr", &SiPMProperties::setDcr)

python/SiPMRandomPy.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ using namespace sipm;
1010
void SiPMRandomPy(py::module& m) {
1111
py::class_<SiPMRandom> SiPMRandom(m, "SiPMRandom");
1212
SiPMRandom.def(py::init<>())
13+
.def("seed", static_cast<void (SiPMRandom::*)(const uint64_t)>(&SiPMRandom::seed))
1314
.def("Rand", static_cast<double (SiPMRandom::*)(void)>(&SiPMRandom::Rand))
1415
.def("randInteger", static_cast<uint32_t (SiPMRandom::*)(const uint32_t)>(&SiPMRandom::randInteger))
1516
.def("randGaussian", static_cast<double (SiPMRandom::*)(const double, const double)>(&SiPMRandom::randGaussian))
@@ -18,6 +19,9 @@ void SiPMRandomPy(py::module& m) {
1819
.def("Rand", static_cast<std::vector<double> (SiPMRandom::*)(const uint32_t)>(&SiPMRandom::Rand))
1920
.def("randGaussian", static_cast<std::vector<double> (SiPMRandom::*)(const double, const double, const uint32_t)>(
2021
&SiPMRandom::randGaussian))
22+
23+
.def("randGaussianF", static_cast<std::vector<float> (SiPMRandom::*)(const float, const float, const uint32_t)>(
24+
&SiPMRandom::randGaussianF))
2125
.def("randInteger",
2226
static_cast<std::vector<uint32_t> (SiPMRandom::*)(const uint32_t, const uint32_t)>(&SiPMRandom::randInteger))
2327
.def("randExponential",

python/SiPMSensorPy.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ void SiPMSensorPy(py::module& m) {
1010
py::class_<SiPMSensor, std::shared_ptr<SiPMSensor>> sipmsensor(m, "SiPMSensor");
1111
sipmsensor.def(py::init<>())
1212
.def(py::init<const SiPMProperties&>())
13-
.def("properties", static_cast<SiPMProperties& (SiPMSensor::*)()>(&SiPMSensor::properties))
1413
.def("properties", static_cast<const SiPMProperties& (SiPMSensor::*)() const>(&SiPMSensor::properties))
15-
.def("hits", &SiPMSensor::hits)
16-
.def("hitsGraph", &SiPMSensor::hitsGraph)
14+
.def("hits", &SiPMSensor::hits, py::return_value_policy::reference_internal)
1715
.def("signal", &SiPMSensor::signal)
1816
.def("rng", static_cast<const SiPMRandom (SiPMSensor::*)() const>(&SiPMSensor::rng))
1917
.def("debug", &SiPMSensor::debug)

0 commit comments

Comments
 (0)