Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed usage of double precision #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Smantii
Copy link

@Smantii Smantii commented Nov 14, 2024

No description provided.

@foolnotion
Copy link
Member

As it stands, there are unneeded changes. We only need to keep these:

diff --git a/source/evaluator.cpp b/source/evaluator.cpp
index c50f8f5..d815db4 100644
--- a/source/evaluator.cpp
+++ b/source/evaluator.cpp
@@ -122,11 +122,11 @@ void InitEval(py::module_ &m)
 
     }, py::arg("tree"), py::arg("dataset"), py::arg("range"), py::arg("target"), py::arg("metric") = "rsquared");
 
-    m.def("PoissonLikelihood", [](py::array_t<float> x, py::array_t<float> y){
+    m.def("PoissonLikelihood", [](py::array_t<Operon::Scalar> x, py::array_t<Operon::Scalar> y){
         return detail::PoissonLikelihood(std::move(x), std::move(y));
     });
 
-    m.def("PoissonLikelihood", [](py::array_t<float> x, py::array_t<float> y, py::array_t<float> w){
+    m.def("PoissonLikelihood", [](py::array_t<Operon::Scalar> x, py::array_t<Operon::Scalar> y, py::array_t<Operon::Scalar> w){
         return detail::PoissonLikelihood(std::move(x), std::move(y), std::move(w));
     });
 
@@ -142,12 +142,12 @@ void InitEval(py::module_ &m)
 
         TDispatch dtable;
 
-        auto result = py::array_t<double>(static_cast<pybind11::ssize_t>(trees.size()));
+        auto result = py::array_t<Operon::Scalar>(static_cast<pybind11::ssize_t>(trees.size()));
         auto buf = result.request();
         auto values = d.GetValues(target).subspan(r.Start(), r.Size());
 
         // TODO: make this run in parallel with taskflow
-        std::transform(trees.begin(), trees.end(), static_cast<double*>(buf.ptr), [&](auto const& t) -> double {
+        std::transform(trees.begin(), trees.end(), static_cast<Operon::Scalar*>(buf.ptr), [&](auto const& t) -> double {
             auto estimated = TInterpreter{dtable, d, t}.Evaluate({}, r);
             return (*error)(estimated, values);
         });

@Smantii
Copy link
Author

Smantii commented Nov 14, 2024

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants