You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Fedora pyswarms package is failing tests
==================================== ERRORS ====================================
_ ERROR at setup of TestGeneralOptimizer.test_train_history[optimizer_history0-cost_history-expected_shape0] _
self = <tests.optimizers.test_general_optimizer.TestGeneralOptimizer object at 0x7fbc9210e510>
request = <SubRequest 'optimizer_history' for <Function test_train_history[optimizer_history0-cost_history-expected_shape0]>>
options = {'c1': 0.3, 'c2': 0.7, 'k': 2, 'p': 2, ...}
@pytest.fixture(params=topologies)
def optimizer_history(self, request, options):
opt = GeneralOptimizerPSO(
n_particles=10,
dimensions=2,
options=options,
topology=request.param,
)
> opt.optimize(sphere, 1000)
tests/optimizers/test_general_optimizer.py:51:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyswarms/single/general_optimizer.py:252: in optimize
self.swarm.best_pos, self.swarm.best_cost = self.top.compute_gbest(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pyswarms.backend.topology.pyramid.Pyramid object at 0x7fbc9230ba90>
swarm = Swarm(position=array([[0.99029359, 0.76531587],
[0.6685371 , 0.85310907],
[0.36142089, 0.14341208],
...6, 1.17473693, 0.15119209, 0.54211531, 0.53914621,
0.4226627 , 1.00655433, 0.39733392, 1.45670983, 0.97363041]))
kwargs = {'c1': 0.3, 'c2': 0.7, 'k': 2, 'p': 2, ...}
pyramid = <scipy.spatial._qhull.Delaunay object at 0x7fbc91f3d350>
def compute_gbest(self, swarm, **kwargs):
"""Update the global best using a pyramid neighborhood approach
This topology uses the :code:`Delaunay` class from :code:`scipy`. To
prevent precision errors in the Delaunay class, custom
:code:`qhull_options` were added. Namely, :code:`QJ0.001 Qbb Qc Qx`.
The meaning of those options is explained in [qhull]. This method is
used to triangulate N-dimensional space into simplices. The vertices of
the simplicies consist of swarm particles. This method is adapted from
the work of Lane et al.[SIS2008]
[SIS2008] J. Lane, A. Engelbrecht and J. Gain, "Particle swarm optimization with spatially
meaningful neighbours," 2008 IEEE Swarm Intelligence Symposium, St. Louis, MO, 2008,
pp. 1-8. doi: 10.1109/SIS.2008.4668281
[qhull] http://www.qhull.org/html/qh-optq.htm
Parameters
----------
swarm : pyswarms.backend.swarms.Swarm
a Swarm instance
Returns
-------
numpy.ndarray
Best position of shape :code:`(n_dimensions, )`
float
Best cost
"""
try:
# If there are less than (swarm.dimensions + 1) particles they are all connected
if swarm.n_particles < swarm.dimensions + 1:
self.neighbor_idx = np.tile(
np.arange(swarm.n_particles), (swarm.n_particles, 1)
)
best_pos = swarm.pbest_pos[np.argmin(swarm.pbest_cost)]
best_cost = np.min(swarm.pbest_cost)
else:
# Check if the topology is static or dynamic and assign neighbors
if (
self.static and self.neighbor_idx is None
) or not self.static:
pyramid = Delaunay(
swarm.position, qhull_options="QJ0.001 Qbb Qc Qx"
)
indices, index_pointer = pyramid.vertex_neighbor_vertices
# Insert all the neighbors for each particle in the idx array
> self.neighbor_idx = np.array(
[
index_pointer[indices[i] : indices[i + 1]]
for i in range(swarm.n_particles)
]
)
E ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (10,) + inhomogeneous part.
pyswarms/backend/topology/pyramid.py:81: ValueError
---------------------------- Captured stderr setup -----------------------------
2023-06-25 10:55:09,612 - pyswarms.single.general_optimizer - INFO - Optimize for 1000 iters with {'c1': 0.3, 'c2': 0.7, 'w': 0.9, 'k': 2, 'p': 2, 'r': 1}
pyswarms.single.general_optimizer: 0%| |0/1000
Most errors seem to be identical to this. Full log: build.log.gz
=========================== short test summary info ============================
FAILED tests/backend/topology/test_pyramid.py::TestPyramidTopology::test_neighbor_idx[True]
FAILED tests/backend/topology/test_pyramid.py::TestPyramidTopology::test_neighbor_idx[False]
FAILED tests/backend/topology/test_pyramid.py::TestPyramidTopology::test_compute_gbest_return_values[True]
FAILED tests/backend/topology/test_pyramid.py::TestPyramidTopology::test_compute_gbest_return_values[False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_neighbor_idx[1-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_neighbor_idx[1-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_neighbor_idx[2-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_neighbor_idx[2-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_neighbor_idx[3-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_neighbor_idx[3-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[1-1-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[1-1-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[1-2-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[1-2-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[2-1-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[2-1-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[2-2-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[2-2-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[3-1-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[3-1-False]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[3-2-True]
FAILED tests/backend/topology/test_random.py::TestRandomTopology::test_compute_gbest_return_values[3-2-False]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_ftol_effect[optimizer0]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_ftol_effect[optimizer1]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_parallel_evaluation[optimizer0]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_parallel_evaluation[optimizer1]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_general_correct_pos[optimizer0]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_general_correct_pos[optimizer1]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_ftol_iter_effect[optimizer0]
FAILED tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_ftol_iter_effect[optimizer1]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history0-cost_history-expected_shape0]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history0-mean_pbest_history-expected_shape1]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history0-mean_neighbor_history-expected_shape2]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history0-pos_history-expected_shape3]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history0-velocity_history-expected_shape4]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history1-cost_history-expected_shape0]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history1-mean_pbest_history-expected_shape1]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history1-mean_neighbor_history-expected_shape2]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history1-pos_history-expected_shape3]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_train_history[optimizer_history1-velocity_history-expected_shape4]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_reset_default_values[optimizer_reset0]
ERROR tests/optimizers/test_general_optimizer.py::TestGeneralOptimizer::test_reset_default_values[optimizer_reset1]
====== 30 failed, 414 passed, 12 skipped, 2 warnings, 12 errors in 33.26s ======
Exception ignored in: <function Pool.__del__ at 0x7fbc91580680>
Traceback (most recent call last):
File "/usr/lib64/python3.11/multiprocessing/pool.py", line 271, in __del__
self._change_notifier.put(None)
File "/usr/lib64/python3.11/multiprocessing/queues.py", line 377, in put
self._writer.send_bytes(obj)
File "/usr/lib64/python3.11/multiprocessing/connection.py", line 199, in send_bytes
self._send_bytes(m[offset:offset + size])
File "/usr/lib64/python3.11/multiprocessing/connection.py", line 410, in _send_bytes
self._send(header + buf)
File "/usr/lib64/python3.11/multiprocessing/connection.py", line 367, in _send
n = write(self._handle, buf)
^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 9] Bad file descriptor
To Reproduce
+ /usr/bin/pytest
============================= test session starts ==============================
platform linux -- Python 3.11.4, pytest-7.3.2, pluggy-1.0.0
rootdir: /builddir/build/BUILD/pyswarms-1.3.0
collected 468 items
Environment (please complete the following information):
OS: Fedora rawhide
PySwarms Version 1.3.0
Python Version 3.11.4
The text was updated successfully, but these errors were encountered:
Describe the bug
The Fedora pyswarms package is failing tests
Most errors seem to be identical to this. Full log:
build.log.gz
To Reproduce
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: