KieranWynn / pyquaternion

A fully featured, pythonic library for representing and using quaternions
http://kieranwynn.github.io/pyquaternion/
MIT License
339 stars 68 forks source link

current demo2.py AttributeError: 'list' object has no attribute 'shape' #68

Open thomasclifford opened 3 years ago

thomasclifford commented 3 years ago

Good day and thanks for your work. I'm trying to run the demo2.py to get the rotating 3d image, and the image window does appear with the axes, but no drawing of the rotating figure. I'm getting a traceback:

Exception in Tkinter callback Traceback (most recent call last): File "c:\bin\python38\lib\tkinter__init.py", line 1883, in call return self.func(args) File "c:\bin\python38\lib\tkinter__init__.py", line 804, in callit func(args) File "c:\bin\python38\lib\site-packages\matplotlib\backends_backend_tk.py", line 253, in idle_draw self.draw() File "c:\bin\python38\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 9, in draw super(FigureCanvasTkAgg, self).draw() File "c:\bin\python38\lib\site-packages\matplotlib\backends\backend_agg.py", line 407, in draw self.figure.draw(self.renderer) File "c:\bin\python38\lib\site-packages\matplotlib\artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "c:\bin\python38\lib\site-packages\matplotlib\figure.py", line 1870, in draw self.canvas.draw_event(renderer) File "c:\bin\python38\lib\site-packages\matplotlib\backend_bases.py", line 1759, in draw_event self.callbacks.process(s, event) File "c:\bin\python38\lib\site-packages\matplotlib\cbook__init__.py", line 229, in process self.exception_handler(exc) File "c:\bin\python38\lib\site-packages\matplotlib\cbook\init.py", line 81, in _exception_printer raise exc File "c:\bin\python38\lib\site-packages\matplotlib\cbook\init__.py", line 224, in process func(*args, **kwargs) File "c:\bin\python38\lib\site-packages\matplotlib\animation.py", line 975, in _start self._init_draw() File "c:\bin\python38\lib\site-packages\matplotlib\animation.py", line 1722, in _init_draw self._drawn_artists = self._init_func() File "demo2-new.py", line 89, in init line.set_3d_properties([]) File "c:\bin\python38\lib\site-packages\mpl_toolkits\mplot3d\art3d.py", line 143, in set_3d_properties zs = np.broadcast_to(zs, xs.shape) AttributeError: 'list' object has no attribute 'shape'

Windows 10

Python: 3.8.6 matplotlib: 3.3.4 numpy: 1.20.1 pyquaternion: 0.9.9

I found one post on stackoverflow that says to use numpy.array, but you're doing that already. Thank you again....... Tom C.

j1s1e1 commented 2 years ago

IF anyone else runs into this, it can be fixed by wrapping both the x and y data in the set_data statements with np.array. Change these two lines to the following:

currently on line 80 in def init(): line.set_data(np.array([]), np.array([]))

currently on line 98 in def animate(i): line.set_data(np.array([start[0], end[0]]), np.array([start[1], end[1]]))

After that the demo should work.

Thanks,

James