Skip to content

Commit

Permalink
Minor fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
matinraayai committed May 3, 2022
1 parent c9bedd6 commit a3e47c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ option(BUILD_MEX "Build mex" ON)

if(BUILD_PYTHON)
add_subdirectory(pybind11)
find_package(PythonLibs 3.8 REQUIRED)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
endif()

Expand Down Expand Up @@ -107,7 +107,7 @@ if (BUILD_PYTHON)
ubj/ubjw.c
pymcx.cpp
)
# pybind11_add_module(example example.cpp)

target_link_libraries(pymcx OpenMP::OpenMP_CXX zmat ZLIB::ZLIB pybind11::module pybind11::lto pybind11::windows_extras)

pybind11_extension(pymcx)
Expand Down
22 changes: 11 additions & 11 deletions src/pymcx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,7 @@ void parseConfig(const py::dict &userCfg, Config &mcxConfig) {
GET_VEC4_FIELD(userCfg, mcxConfig, srcparam1, float);
GET_VEC4_FIELD(userCfg, mcxConfig, srcparam2, float);
GET_VEC4_FIELD(userCfg, mcxConfig, srciquv, float);
std::cout << "Parsing volume:" << std::endl;
parseVolume(userCfg, mcxConfig);
std::cout << "Parsed volume" << std::endl;

if (userCfg.contains("detpos")) {
auto fStyleVolume = py::array_t<float, py::array::f_style | py::array::forcecast>::ensure(userCfg["detpos"]);
Expand Down Expand Up @@ -800,13 +798,17 @@ py::dict pyMcxInterface(const py::dict &userCfg) {
return output;
}

py::dict pyMcxInterfaceWargs(py::args args, const py::kwargs &kwargs) {
return pyMcxInterface(kwargs);
}

void printMCXUsage() {
std::cout
<< "PyMCX v2021.2\nUsage:\n flux, detphoton, vol, seeds = pymcx.mcx(cfg);\n\nRun 'help(pymcx.mcx)' for more details.\n";
<< "PyMCX v2021.2\nUsage:\n output = pymcx.mcx(cfg);\n\nRun 'help(pymcx.mcx)' for more details.\n";
}

py::dict pyMcxInterfaceWargs(py::args args, const py::kwargs &kwargs) {
if (py::len(kwargs) == 0) {
printMCXUsage();
return {};
}
return pyMcxInterface(kwargs);
}

py::list getGPUInfo() {
Expand Down Expand Up @@ -846,12 +848,10 @@ py::list getGPUInfo() {

PYBIND11_MODULE(pymcx, m) {
m.doc() = "PyMCX: Monte Carlo eXtreme Python Interface, www.mcx.space.";
m.def("mcx", &pyMcxInterface, "Runs MCX", py::call_guard<py::scoped_ostream_redirect,
m.def("mcx", &pyMcxInterface, "Runs MCX with the given config.", py::call_guard<py::scoped_ostream_redirect,
py::scoped_estream_redirect>());
m.def("mcx", &pyMcxInterfaceWargs, "Runs MCX", py::call_guard<py::scoped_ostream_redirect,
m.def("mcx", &pyMcxInterfaceWargs, "Runs MCX with the given config.", py::call_guard<py::scoped_ostream_redirect,
py::scoped_estream_redirect>());
m.def("mcx", &printMCXUsage, "", py::call_guard<py::scoped_ostream_redirect,
py::scoped_estream_redirect>());
m.def("gpu_info",
&getGPUInfo,
"Prints out the list of CUDA-capable devices attached to this system.",
Expand Down

0 comments on commit a3e47c8

Please sign in to comment.