Skip to content

Commit

Permalink
Use HAVE_PYTHON_EMBED in goal code
Browse files Browse the repository at this point in the history
  • Loading branch information
etphipp authored Aug 15, 2024
1 parent 4facc50 commit d8524d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Genten_AlgParams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "Genten_IndxArray.hpp"
#include "Genten_Ptree.hpp"

#ifdef HAVE_PYTHON
#ifdef HAVE_PYTHON_EMBED
#include "pybind11/pytypes.h"
#endif

Expand Down Expand Up @@ -114,7 +114,7 @@ namespace Genten {
GCP_Goal_Method::type goal_method; // Way of supplying goal function
std::string python_module_name; // Module name for python goal
std::string python_object_name; // Object name for python module goal
#ifdef HAVE_PYTHON
#ifdef HAVE_PYTHON_EMBED
pybind11::object python_object; // Python object for python goal
#endif

Expand Down
12 changes: 6 additions & 6 deletions src/Genten_GCP_Goal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "Genten_Ktensor.hpp"
#include "Genten_AlgParams.hpp"

#ifdef HAVE_PYTHON
#ifdef HAVE_PYTHON_EMBED
#include <pybind11/embed.h>
#endif

Expand Down Expand Up @@ -76,7 +76,7 @@ namespace Genten {
const ttb_real s) const = 0;
};

#ifdef HAVE_PYTHON
#ifdef HAVE_PYTHON_EMBED
// A goal function implemented as a python object
template <typename ExecSpace>
class __attribute__((visibility("default"))) GCP_PythonObjectGoal :
Expand Down Expand Up @@ -158,14 +158,14 @@ namespace Genten {
if (algParams.goal_method == GCP_Goal_Method::None)
goal = nullptr;
else if (algParams.goal_method == GCP_Goal_Method::PythonObject) {
#ifdef HAVE_PYTHON
#ifdef HAVE_PYTHON_EMBED
goal = new GCP_PythonObjectGoal<ExecSpace>(X, M, algParams.python_object);
#else
Genten::error("Python object goal requires python!");
Genten::error("Python object goal requires embedded python (configure with ENABLE_PYTHON_EMBED=ON)!");
#endif
}
else if (algParams.goal_method == GCP_Goal_Method::PythonModule) {
#ifdef HAVE_PYTHON
#ifdef HAVE_PYTHON_EMBED
try {
auto python_module =
pybind11::module_::import(algParams.python_module_name.c_str());
Expand All @@ -184,7 +184,7 @@ namespace Genten {
Genten::error(e.what());
}
#else
Genten::error("Python module goal requires python!");
Genten::error("Python module goal requires embedded python (configure with ENABLE_PYTHON_EMBED=ON)!");
#endif
}
else
Expand Down

0 comments on commit d8524d3

Please sign in to comment.