-
Notifications
You must be signed in to change notification settings - Fork 334
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
Adding verbose switch and fixing unclosed pool #395
Conversation
The verbose switch was added to optimize() method to enable or disable the logs and progress bar.
The verbose switch was added to optimize() method. Pool of Processes is closed at the end of calculations
Pool of Processes is closed at the end of calculations.
Pool of Processes is closed at the end of calculations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checks have failed.
I've only got a chance to give have a quick look at the changes. The logging part seems to be fine.
The problem is mostly with the pool.close()
. The pool is set to None
when not using multi-threading. #394
You need to add that case to the code.
# Setup Pool of processes for parallel evaluation
pool = None if n_processes is None else mp.Pool(n_processes)
So you need to change the pool.close()
to something along the lines of
if pool is not None:
pool.close()
I would also recommend making the same changes to BinaryPSO
to keep the codebase consistent. @ljvmiranda921 can take a call on this. 👍
PS: Make sure the the tests pass locally by running pytest .
pool.close() was fixed if n_process is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes for the general optimizer, global, and local best are good. Echoing @nishnash54 , would you mind to apply the same changes to the BinaryPSO, @msat59 ? (https://github.com/ljvmiranda921/pyswarms/blob/master/pyswarms/discrete/binary.py)
Again, thank you @msat59 for taking the time and the patience to learn Github (based from your comment in the referenced Issue) to make this PR 🙇♂️ Also, thank you @nishnash54 for taking the time to review and help @msat59 out, I appreciate your help! Next steps: For completeness, let's apply the same changes to |
pool.close() and verbose switch were added to optimize() method.
Thanks for this @msat59 and congratulations to your first contribution to Pyswarms! Will merge this in now and make a release this weekend. @all-contributors please add @msat59 to code and bugs |
I've put up a pull request to add @msat59! 🎉 |
Description
The verbose switch was added to optimize() method. In addition, the pool of processes was closed at the end of calculations.
Related Issue
Types of changes
The pool of processes was not being closed at the end of calculations. It is being closed now.
The verbose (=True or False) is added to optimize() method to turn on or off the logging and progress bar.