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

Adding verbose switch and fixing unclosed pool #395

Merged
merged 9 commits into from
Apr 29, 2020
Merged

Adding verbose switch and fixing unclosed pool #395

merged 9 commits into from
Apr 29, 2020

Conversation

msat59
Copy link
Contributor

@msat59 msat59 commented Apr 24, 2020

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

  • Bug fix (non-breaking change which fixes an issue)
    The pool of processes was not being closed at the end of calculations. It is being closed now.
  • New feature (non-breaking change which adds functionality)
    The verbose (=True or False) is added to optimize() method to turn on or off the logging and progress bar.

msat59 added 5 commits April 24, 2020 18:01
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.
Copy link
Contributor

@nishnash54 nishnash54 left a 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 .

@msat59
Copy link
Contributor Author

msat59 commented Apr 24, 2020

pool.close() was fixed if n_process is None

Copy link
Owner

@ljvmiranda921 ljvmiranda921 left a 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)

@ljvmiranda921
Copy link
Owner

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 BinaryPSO (https://github.com/ljvmiranda921/pyswarms/blob/master/pyswarms/discrete/binary.py) so that everything is covered.

@ljvmiranda921 ljvmiranda921 requested a review from whzup April 25, 2020 08:36
pool.close() and verbose switch were added to optimize() method.
@ljvmiranda921 ljvmiranda921 merged commit e617733 into ljvmiranda921:master Apr 29, 2020
@ljvmiranda921
Copy link
Owner

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

@allcontributors
Copy link
Contributor

@ljvmiranda921

I've put up a pull request to add @msat59! 🎉

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.

3 participants