Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SolveTimer() #400

Merged
merged 5 commits into from
Aug 2, 2022
Merged

Add SolveTimer() #400

merged 5 commits into from
Aug 2, 2022

Conversation

dbrakenhoff
Copy link
Member

Short Description

Add a timer for model optimization. I was running into some extremely slow running models somewhere within my 400 model dataset, and found this useful in diagnosing the issue, by printing the model name in my loop and then showing some record of elapsed time and no. of iterations.

It does require tqdm to be installed, so I put it into a different file that is not imported by default. Due to the optional nature of the dependency I haven't added any examples or tests.

Usage:

from pastas.timer import SolveTimer

with SolveTimer() as t:
    ml.solve(callback=t.timer)

This prints the following to the console:

Optimization progress: 73it [00:01, 67.68it/s]

Checklist before PR can be merged:

  • closes issue #xxxx
  • is documented
  • PEP8 compliant code
  • tests added / passed
  • Example Notebook (for new features)
  • API changes documented in Release Notes

- print number of iterations and elapsed time to console while running ml.solve()
- see docstring for usage
@dbrakenhoff
Copy link
Member Author

Oops I committed some stuff in here that should have gone straight to dev. If PR is not accepted, I'll make the changes again on dev.

@raoulcollenteur raoulcollenteur merged commit 3b82576 into dev Aug 2, 2022
@raoulcollenteur raoulcollenteur deleted the solve_timer branch August 2, 2022 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants