Open colinww opened 4 years ago
I should add that I don't think this is a bug with tqdm, since it is more related to my specific needs. But I think in general, if a floating-point total
is supported, it is dangerous to use the delta-update method, since a running sum of floating point numbers (and comparisons with floats, etc) can lead to all sorts of imprecisions.
I second @colinww. In fact, I think there should be a method set_progress()
or something, which sets the current progression instead of just updating by a number.
First of all, I really love this module, thank you for developing it! I am using it to show the progress of a simulation. The aspects of this simulation are:
The simulator internally computes the timestep using a custom number format that is more precise than double. It can report the current simulation time approximately as a double. So the original code does something like this:
Thus, I am updating the progress bar using the approximate (as double-precision) deltas
self.csim.tedge - self.csim.pedge
. The problem is then that the approximation errors are accumulated and over long simulations, theself.n
within tqdm diverges from the actual simulation time. So then this happens:So in this case, all the timestep approximation errors were biased slightly positive, so eventually tqdm thinks we have exceeded our total (by about 0.008 / 2.0). To work around this, I have changed my update to look like this:
This seems to work. But is this the "official" way to do this? Essentially I want an update method that takes in an absolute position, rather than a delta increment. Does this exist? Thank you!