Skip to content

Commit

Permalink
Get descriptions and possible options in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
BUYT-1 committed Jul 10, 2023
1 parent 2edb473 commit 2c4bd78
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python_bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ PYBIND11_MODULE(desbordante, module) {
"Load data after all options have been set by SetOption calls")
.def("get_needed_options", &PyAlgorithmBase::GetNeededOptions,
"Get names of options the algorithm needs")
.def("get_possible_options", &PyAlgorithmBase::GetPossibleOptions,
"Get names of options the algorithm may request")
.def("get_description", &PyAlgorithmBase::GetDescription,
"Get description of an option of this algorithm")
.def("set_option", &PyAlgorithmBase::SetOption, "option_name"_a,
"option_value"_a = pybind11::none(), "Set option value")
.def("get_option_type", &PyAlgorithmBase::GetOptionType, "option_name"_a,
Expand Down
8 changes: 8 additions & 0 deletions python_bindings/py_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ std::unordered_set<std::string_view> PyAlgorithmBase::GetNeededOptions() const {
return algorithm_->GetNeededOptions();
}

std::unordered_set<std::string_view> PyAlgorithmBase::GetPossibleOptions() const {
return algorithm_->GetPossibleOptions();
}

std::string_view PyAlgorithmBase::GetDescription(std::string_view option_name) const {
return algorithm_->GetDescription(option_name);
}

py::frozenset PyAlgorithmBase::GetOptionType(std::string_view option_name) const {
auto type_index = algorithm_->GetTypeIndex(option_name);
if (type_index == void_index)
Expand Down
4 changes: 4 additions & 0 deletions python_bindings/py_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class PyAlgorithmBase {

[[nodiscard]] std::unordered_set<std::string_view> GetNeededOptions() const;

[[nodiscard]] std::unordered_set<std::string_view> GetPossibleOptions() const;

[[nodiscard]] std::string_view GetDescription(std::string_view option_name) const;

[[nodiscard]] pybind11::frozenset GetOptionType(std::string_view option_name) const;

// For pandas dataframes
Expand Down

0 comments on commit 2c4bd78

Please sign in to comment.