Skip to content

Instantly share code, notes, and snippets.

@thomaslima
Last active January 20, 2022 10:53
Show Gist options
  • Save thomaslima/d8e795c908f334931354da95acb97e54 to your computer and use it in GitHub Desktop.
Save thomaslima/d8e795c908f334931354da95acb97e54 to your computer and use it in GitHub Desktop.
Progress bar of scipy ode solver with tqdm
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dschick
Copy link

dschick commented Oct 12, 2020

thanks for the nice example.
I have implemented your example in my code and encountered one major issue which is related to the way the ode solver works:

in my case the ode solver does not go monotonically from small to larger time steps (at least not, when I do not restrict the time stepping).
This leads to the fact, that the solver first makes a very large step and then goes again back in time until it starts actually to do monotonic steps.

I was wondering if you might already found a solution for this type of problem, instead of restricting the stepping of the solver?

@thomaslima
Copy link
Author

Thank you for pointing this out. The issue is that tqdm doesn't offer a native manual update operation where you can go back in time. They only offer this .update method which is supposed to be used with "increments". If I may ask, what is the behavior of the progress bar in your ODE? How bit is that first step compared to the T1-T0 range?

A workaround you can use is to catch the desired behavior using if statements and only call pbar.update when you know for sure that t is increasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment