Bug 2210608
| Summary: | python-pyswarms: FTBFS in Fedora Rawhide | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Orion Poplawski <orion> |
| Component: | python-pyswarms | Assignee: | Iztok Fister Jr. <iztok> |
| Status: | NEW --- | QA Contact: | |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 39 | CC: | iztok, neuro-sig, sanjay.ankur |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Linux | ||
| URL: | https://koschei.fedoraproject.org/package/python-pyswarms | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | Type: | --- | |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Orion Poplawski
2023-05-29 00:22:10 UTC
I see an issue and PR have been filed already: https://github.com/ljvmiranda921/pyswarms/issues/508 https://github.com/ljvmiranda921/pyswarms/pull/509 Iztok: could we carry the patch in the meantime to fix this FTBFS? Please let us know if there's anything we can do to help :) Cheers, I've applied the matplotlib patch, but it still fails:
_ ERROR at setup of TestGeneralOptimizer.test_train_history[optimizer_history0-cost_history-expected_shape0] _
self = <tests.optimizers.test_general_optimizer.TestGeneralOptimizer object at 0xffff6f8dde10>
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 0xffff6f89ffd0>
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 0xffff6f893290>
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
I've filed https://github.com/ljvmiranda921/pyswarms/issues/516
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle. Changing version to 39. |