Proposal for new class
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:
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.
@o11c thoughts?
I think this is a substantial improvement.
@casperdcl ...
The problem with this is you don't give tqdm a total even though one is clearly available. That means no bar and eta