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

Replace multiprocessing with multiprocess. Fixes #480. #504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyswarms/backend/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ def compute_objective_function(swarm, objective_func, pool=None, **kwargs):
a Swarm instance
objective_func : function
objective function to be evaluated
pool: multiprocessing.Pool
multiprocessing.Pool to be used for parallel particle evaluation
pool: multiprocess.Pool
multiprocess.Pool to be used for parallel particle evaluation
kwargs : dict
arguments for the objective function

Expand Down
2 changes: 1 addition & 1 deletion pyswarms/discrete/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

# Import modules
import numpy as np
import multiprocessing as mp
import multiprocess as mp

from collections import deque

Expand Down
2 changes: 1 addition & 1 deletion pyswarms/single/general_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

# Import modules
import numpy as np
import multiprocessing as mp
import multiprocess as mp

from collections import deque

Expand Down
2 changes: 1 addition & 1 deletion pyswarms/single/global_best.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

# Import modules
import numpy as np
import multiprocessing as mp
import multiprocess as mp

from collections import deque

Expand Down
2 changes: 1 addition & 1 deletion pyswarms/single/local_best.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

# Import modules
import numpy as np
import multiprocessing as mp
import multiprocess as mp

from collections import deque

Expand Down
2 changes: 1 addition & 1 deletion pyswarms/utils/plotters/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from attr import attrib, attrs
from attr.validators import instance_of
from matplotlib import cm, colors
import multiprocessing as mp
import multiprocess as mp


@attrs
Expand Down
2 changes: 1 addition & 1 deletion pyswarms/utils/plotters/plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# Import modules
import matplotlib.pyplot as plt
import numpy as np
import multiprocessing as mp
import multiprocess as mp
from matplotlib import animation, cm
from mpl_toolkits.mplot3d import Axes3D

Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pytest-cov==2.10.1
pytest==6.1.2
python-dateutil==2.7.5
pytz==2018.9
pyyaml==3.13
pyyaml==6.0
pyzmq==18.0.1
requests==2.21.0
scikit-learn==0.21.1
Expand All @@ -81,6 +81,7 @@ virtualenv==16.3.0
wcwidth==0.1.7
webencodings==0.5.1
wheel==0.31.1
multiprocess==0.70.14

# The following packages are considered to be unsafe in a requirements file:
# setuptools
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ attrs
tqdm
future
pyyaml
multiprocess
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ scipy==1.2.0
six==1.12.0
tqdm==4.24.0
pyyaml==5.1.1
multiprocess==0.70.14
4 changes: 2 additions & 2 deletions tests/optimizers/abc_test_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def test_ftol_effect(self, options, optimizer):

def test_parallel_evaluation(self, obj_without_args, optimizer, options):
"""Test if parallelization breaks the optimization process"""
import multiprocessing
import multiprocess

opt = optimizer(100, 2, options=options)
opt.optimize(
obj_without_args, 2000, n_processes=multiprocessing.cpu_count()
obj_without_args, 2000, n_processes=multiprocess.cpu_count()
)
assert np.array(opt.cost_history).shape == (2000,)

Expand Down
4 changes: 2 additions & 2 deletions tests/optimizers/test_general_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def test_ftol_effect(self, optimizer):

def test_parallel_evaluation(self, obj_without_args, optimizer):
"""Test if parallelization breaks the optimization process"""
import multiprocessing
import multiprocess

optimizer.optimize(
obj_without_args, 2000, n_processes=multiprocessing.cpu_count()
obj_without_args, 2000, n_processes=multiprocess.cpu_count()
)
assert np.array(optimizer.cost_history).shape == (2000,)

Expand Down
4 changes: 2 additions & 2 deletions tests/utils/plotters/test_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def test_mesh_hidden_function_shape(mesher):

def test_parallel_mesh(mesher):
"""Test if parallelization breaks the optimization process"""
import multiprocessing
import multiprocess

xx, yy, zz = _mesh(mesher)
xx_p, yy_p, zz_p = _mesh(mesher, n_processes=multiprocessing.cpu_count())
xx_p, yy_p, zz_p = _mesh(mesher, n_processes=multiprocess.cpu_count())
assert (
xx.shape
== yy.shape
Expand Down