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

IndexError: index 0 is out of bounds for axis 1 with size 0 #43

Open
alberaja opened this issue Apr 16, 2023 · 3 comments
Open

IndexError: index 0 is out of bounds for axis 1 with size 0 #43

alberaja opened this issue Apr 16, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@alberaja
Copy link

alberaja commented Apr 16, 2023

I receive this same error trying launching master with:
swarm fireflies 14 --function michalewicz --alpha 0.5 --beta 0.2 --gamma 1.0
swarm whales 14 -f michalewicz -n 10
swarm wolves 10 -f=michalewicz

(...)
2023-04-16 17:58:14,875 [INFO ] Current best value: -0.9966775719782092, Overall best value: -1.7399912676909937
2023-04-16 17:58:14,877 [INFO ] Current best value: -1.0013626000092621, Overall best value: -1.7399912676909937
Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\Scripts\swarm.exe_main
.py", line 7, in
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\swarmlib_main
.py", line 86, in run_swarm
algorithm(args)
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\swarmlib\gwo\main.py", line 19, in _run_gwo
problem.replay()
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\swarmlib\util\problem_base.py", line 25, in replay
self._visualizer.replay()
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\swarmlib\util\base_visualizer.py", line 85, in replay
_ = animation.FuncAnimation(self._fig, self._animate, frames=frames, interval=self.__frame_interval,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\matplotlib\animation.py", line 1694, in init
super().init(fig, **kwargs)
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\matplotlib\animation.py", line 1416, in init
super().init(fig, event_source=event_source, *args, **kwargs)
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\matplotlib\animation.py", line 880, in init
self._setup_blit()
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\matplotlib\animation.py", line 1214, in _setup_blit
self._init_draw()
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\matplotlib\animation.py", line 1750, in _init_draw
self._drawn_artists = self._init_func()
^^^^^^^^^^^^^^^^^
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\swarmlib\util\base_visualizer.py", line 94, in _init
self.__particles.set_offsets([[]])
File "C:\Users\Alberto\AppData\Roaming\Python\Python311\site-packages\matplotlib\collections.py", line 551, in set_offsets
(np.asanyarray(self.convert_xunits(offsets[:, 0]), float),
~~~~~~~^^^^^^
IndexError: index 0 is out of bounds for axis 1 with size 0

(...)
AttributeError: 'FuncAnimation' object has no attribute '_resize_id'

@HaaLeo
Copy link
Owner

HaaLeo commented Apr 17, 2023

Hi @alberaja, thx for your contribution. I've never tested the package with python 3.11. Can you pls try to setup a virtual environment with python 3.9 and install the package there as described in the README.md?

@HaaLeo HaaLeo added the bug Something isn't working label Apr 17, 2023
@ivanmilevtues
Copy link

ivanmilevtues commented Jan 1, 2024

Hey, we've encountered similar problem on Python 3.7. We've worked around the problem by editing line 94 in base_visualiser from:
self.__particles.set_offset([[]]) to self.__particles.set_offset(np.random.rand(5, 2) * 4.
Seems to fix the problem as it is related to offset being empty 2d array.

Best Regards

@HaaLeo
Copy link
Owner

HaaLeo commented Jan 3, 2024

Hi @ivanmilevtues thx for reporting this possible fix. I hope I find time the next few days to test it and maybe release the fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants