Skip to content

Commit

Permalink
Fix python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
oir committed Nov 30, 2023
1 parent 04d2fc2 commit 83458e3
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions python/barkeep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ template <typename T>
py::object make_counter(value_t<T> value,
std::string msg,
double interval,
Speed speed,
std::optional<double> discount,
std::string speed_unit) {
Counter_<T> counter;
*counter.work = value;
counter.message(msg);
counter.interval(interval);
counter.speed(speed);
counter.speed(discount);
counter.speed_unit(speed_unit);
return py::cast(counter);
};
Expand Down Expand Up @@ -73,15 +73,15 @@ py::object make_progress_bar(value_t<T> value,
std::string msg,
double interval,
ProgressBarStyle style,
Speed speed,
std::optional<double> discount,
std::string speed_unit) {
ProgressBar_<T> bar;
*bar.work = value;
bar.total(total);
bar.message(msg);
bar.interval(interval);
bar.style(style);
bar.speed(speed);
bar.speed(discount);
bar.speed_unit(speed_unit);
return py::cast(bar);
};
Expand Down Expand Up @@ -128,12 +128,6 @@ PYBIND11_MODULE(barkeep, m) {
.value("Arrow", ProgressBarStyle::Arrow)
.export_values();

py::enum_<Speed>(m, "Speed")
.value("No", Speed::None)
.value("Last", Speed::Last)
.value("Overall", Speed::Overall)
.export_values();

py::enum_<DType>(m, "DType")
.value("Int", DType::Int)
.value("Float", DType::Float)
Expand Down Expand Up @@ -165,7 +159,7 @@ PYBIND11_MODULE(barkeep, m) {
[](double value, // TODO: Make value match the specified dtype
std::string msg,
double interval,
Speed speed,
std::optional<double> speed,
std::string speed_unit,
DType dtype) -> py::object {
switch (dtype) {
Expand All @@ -185,7 +179,7 @@ PYBIND11_MODULE(barkeep, m) {
"value"_a = 0,
"message"_a = "",
"interval"_a = 1.,
"speed"_a = Speed::None,
"speed"_a = py::none(),
"speed_unit"_a = "",
"dtype"_a = DType::Int);

Expand All @@ -203,7 +197,7 @@ PYBIND11_MODULE(barkeep, m) {
std::string msg,
double interval,
ProgressBarStyle style,
Speed speed,
std::optional<double> speed,
std::string speed_unit,
DType dtype) -> py::object {
switch (dtype) {
Expand All @@ -227,7 +221,7 @@ PYBIND11_MODULE(barkeep, m) {
"message"_a = "",
"interval"_a = 0.1,
"style"_a = ProgressBarStyle::Blocks,
"speed"_a = Speed::None,
"speed"_a = py::none(),
"speed_unit"_a = "",
"dtype"_a = DType::Int);

Expand Down

0 comments on commit 83458e3

Please sign in to comment.