You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, in order to add a progress bar to a classic for loop, they'd have to change something like this:
for (int i = 0; i < 10; ++i) {
// ...
}
into this:
for (int i : trange(10)) {
// ...
}
That might be a little bit of a hassle and might ruin the code's style in the eye of the user. So I propose a small class that lets you replace it with this:
for (tqdm::whatever i = 0; i < 10; ++i) {
// ...
}
I wrote a little bit of code to this effect:
class twhatever {
tqdm foo;
int value;
public:
inline twhatever(int initial) {
value = initial;
foo = tqdm(initial); // or whatever intialization
}
inline operator int() const {return value;}
twhatever inline operator++ () {
value++;
foo.update(1);
return *this;
}
};
It implicitly converts to an integer (not usually good, but great in this case) and the ++ operator updates the bar. Add the other postfix/prefix decrement/increment, and it's good to go.
It would make implementing progress bars just that little bit easier.
My writing is a bit sloppy and came out in reverse. I think it's a good idea.
What do you guys think? And I can implement this myself if it is decided as such, it's a pretty simple task.
The text was updated successfully, but these errors were encountered:
This idea might be crazy, maybe, I don't know.
Currently, in order to add a progress bar to a classic for loop, they'd have to change something like this:
into this:
That might be a little bit of a hassle and might ruin the code's style in the eye of the user. So I propose a small class that lets you replace it with this:
I wrote a little bit of code to this effect:
It implicitly converts to an integer (not usually good, but great in this case) and the ++ operator updates the bar. Add the other postfix/prefix decrement/increment, and it's good to go.
It would make implementing progress bars just that little bit easier.
My writing is a bit sloppy and came out in reverse. I think it's a good idea.
What do you guys think? And I can implement this myself if it is decided as such, it's a pretty simple task.
The text was updated successfully, but these errors were encountered: