1+ #include < format>
12#include < random>
23
34#include < nanobind/nanobind.h>
5+ #include < nanobind/stl/string.h>
46
57#include < reticula/processes.hpp>
68
@@ -11,6 +13,12 @@ void define_processes(nanobind::module_& m) {
1113 nanobind::init<double , double >(), nanobind::arg (" exponent" ),
1214 nanobind::arg (" mean" ),
1315 nanobind::call_guard<nanobind::gil_scoped_release>())
16+ .def (
17+ " __repr__" ,
18+ [](const power_law& pl) {
19+ return std::format (
20+ " reticula.power_law(exponent={}, mean={})" , pl.exponent (), pl.mean ());
21+ })
1422 .def (
1523 " __call__" , [](const power_law& pl, std::mt19937_64& g) { return pl (g); },
1624 nanobind::arg (" generator" ),
@@ -30,6 +38,13 @@ void define_processes(nanobind::module_& m) {
3038 nanobind::init<double , double >(), nanobind::arg (" exponent" ),
3139 nanobind::arg (" mean" ),
3240 nanobind::call_guard<nanobind::gil_scoped_release>())
41+ .def (
42+ " __repr__" ,
43+ [](const residual_power_law& rpl) {
44+ return std::format (
45+ " reticula.residual_power_law(exponent={}, mean={})" , rpl.exponent (),
46+ rpl.mean ());
47+ })
3348 .def (
3449 " __call__" ,
3550 [](const residual_power_law& rpl, std::mt19937_64& g) { return rpl (g); },
@@ -52,6 +67,14 @@ void define_processes(nanobind::module_& m) {
5267 nanobind::arg (" alpha" ), nanobind::arg (" theta" ),
5368 nanobind::arg (" phi" ) = 0.0 ,
5469 nanobind::call_guard<nanobind::gil_scoped_release>())
70+ .def (
71+ " __repr__" ,
72+ [](const hawkes_univariate_exponential& hue) {
73+ return std::format (
74+ " reticula.hawkes_univariate_exponential(mu={}, alpha={}, theta={}, "
75+ " phi={})" ,
76+ hue.mu (), hue.alpha (), hue.theta (), hue.phi ());
77+ })
5578 .def (
5679 " __call__" ,
5780 [](hawkes_univariate_exponential& hue, std::mt19937_64& g) {
@@ -76,6 +99,11 @@ void define_processes(nanobind::module_& m) {
7699 .def (
77100 nanobind::init<double >(), nanobind::arg (" mean" ),
78101 nanobind::call_guard<nanobind::gil_scoped_release>())
102+ .def (
103+ " __repr__" ,
104+ [](const delta_distribution& dd) {
105+ return std::format (" reticula.delta_distribution(mean={})" , dd.mean ());
106+ })
79107 .def (
80108 " __call__" ,
81109 [](const delta_distribution& dd, std::mt19937_64& g) { return dd (g); },
@@ -90,6 +118,12 @@ void define_processes(nanobind::module_& m) {
90118 .def (
91119 nanobind::init<double >(), nanobind::arg (" lmbda" ),
92120 nanobind::call_guard<nanobind::gil_scoped_release>())
121+ .def (
122+ " __repr__" ,
123+ [](const std::exponential_distribution<double >& ed) {
124+ return std::format (
125+ " reticula.exponential_distribution(lmbda={})" , ed.lambda ());
126+ })
93127 .def (
94128 " __call__" ,
95129 [](std::exponential_distribution<double >& ed, std::mt19937_64& g) {
@@ -106,6 +140,12 @@ void define_processes(nanobind::module_& m) {
106140 .def (
107141 nanobind::init<double , double >(), nanobind::arg (" a" ), nanobind::arg (" b" ),
108142 nanobind::call_guard<nanobind::gil_scoped_release>())
143+ .def (
144+ " __repr__" ,
145+ [](const std::uniform_real_distribution<double >& urd) {
146+ return std::format (
147+ " reticula.uniform_real_distribution(a={}, b={})" , urd.a (), urd.b ());
148+ })
109149 .def (
110150 " __call__" ,
111151 [](std::uniform_real_distribution<double >& urd, std::mt19937_64& g) {
@@ -125,6 +165,12 @@ void define_processes(nanobind::module_& m) {
125165 .def (
126166 nanobind::init<double , double >(), nanobind::arg (" m" ), nanobind::arg (" s" ),
127167 nanobind::call_guard<nanobind::gil_scoped_release>())
168+ .def (
169+ " __repr__" ,
170+ [](const std::lognormal_distribution<double >& lnd) {
171+ return std::format (
172+ " reticula.lognormal_distribution(m={}, s={})" , lnd.m (), lnd.s ());
173+ })
128174 .def (
129175 " __call__" ,
130176 [](std::lognormal_distribution<double >& lnd, std::mt19937_64& g) {
@@ -144,6 +190,13 @@ void define_processes(nanobind::module_& m) {
144190 nanobind::init<double , double >(), nanobind::arg (" alpha" ),
145191 nanobind::arg (" beta" ),
146192 nanobind::call_guard<nanobind::gil_scoped_release>())
193+ .def (
194+ " __repr__" ,
195+ [](const std::gamma_distribution<double >& gd) {
196+ return std::format (
197+ " reticula.gamma_distribution(alpha={}, beta={})" , gd.alpha (),
198+ gd.beta ());
199+ })
147200 .def (
148201 " __call__" ,
149202 [](std::gamma_distribution<double >& gd, std::mt19937_64& g) {
@@ -162,6 +215,12 @@ void define_processes(nanobind::module_& m) {
162215 .def (
163216 nanobind::init<double , double >(), nanobind::arg (" a" ), nanobind::arg (" b" ),
164217 nanobind::call_guard<nanobind::gil_scoped_release>())
218+ .def (
219+ " __repr__" ,
220+ [](const std::weibull_distribution<double >& wd) {
221+ return std::format (
222+ " reticula.weibull_distribution(a={}, b={})" , wd.a (), wd.b ());
223+ })
165224 .def (
166225 " __call__" ,
167226 [](std::weibull_distribution<double >& wd, std::mt19937_64& g) {
@@ -181,6 +240,11 @@ void define_processes(nanobind::module_& m) {
181240 .def (
182241 nanobind::init<double >(), nanobind::arg (" p" ),
183242 nanobind::call_guard<nanobind::gil_scoped_release>())
243+ .def (
244+ " __repr__" ,
245+ [](const std::geometric_distribution<std::uint64_t >& gd) {
246+ return std::format (" reticula.geometric_distribution(p={})" , gd.p ());
247+ })
184248 .def (
185249 " __call__" ,
186250 [](std::geometric_distribution<std::uint64_t >& gd, std::mt19937_64& g) {
0 commit comments