From d8580214d5fe1fb71ad483673ae0a9f6de6c98f7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 1 May 2024 10:23:09 -0500 Subject: [PATCH] xo-pyunit: + addition --- src/pyunit/pyunit.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pyunit/pyunit.cpp b/src/pyunit/pyunit.cpp index 08486e77..206129db 100644 --- a/src/pyunit/pyunit.cpp +++ b/src/pyunit/pyunit.cpp @@ -67,6 +67,25 @@ namespace xo { .def("reciprocal", &XoQuantity::reciprocal) .def("rescale", &XoQuantity::rescale, py::arg("unit")) + + .def("__add__", + [](const XoQuantity & x, const XoQuantity & y) + { + return x + y; + }) + + .def("__add__", + [](const XoQuantity & x, double y) + { + return x + y; + }) + + .def("__radd__", + [](double y, const XoQuantity & x) + { + return x + y; + }) + .def("__mul__", [](const XoQuantity & x, const XoQuantity & y) {