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

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

Smantii
Copy link
Contributor

@Smantii Smantii commented Nov 14, 2024

Fixes compilation error in the double-precision Operon backend.

@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
Contributor Author

Smantii commented Nov 14, 2024

Done!

@foolnotion
Copy link
Member

Done!

Hi, sorry for being pedantic but we don't want to have all these commits in the history (the last one basically reverts the previous changes). Instead, please soft-reset to HEAD~3, then commit only the required changes and force-push.

@Smantii
Copy link
Contributor Author

Smantii commented Nov 15, 2024

Done, now the changes are made in a single commit.

@foolnotion
Copy link
Member

Done, now the changes are made in a single commit.

Looks good, thanks!

@foolnotion foolnotion merged commit acf6a07 into heal-research:main Nov 15, 2024
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