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

compilation failed - Attribute error in example I of continuos time convolution #31

Open
TheFabulousDeath opened this issue Apr 30, 2023 · 1 comment

Comments

@TheFabulousDeath
Copy link

TheFabulousDeath commented Apr 30, 2023

I tried running the example in Binder and locally and both versions had the same (lengthy) compilation error. I cut out the parts of the message that just referenced elements in conda, so here is the shortened one:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], line 6
      2 xB = h
      3 y = sp.integrate(xA.subs(t, t-tau) * xB.subs(t, tau),
      4                  (tau, 0, t))  # for causal signals
----> 6 anim = animate_convolution(
      7     x=xA,
      8     h=xB,
      9     y=y,
     10     td=np.arange(-2, 10, .1),
     11     taud=np.arange(-10, 10, 0.01),
     12     xlim=(-2, 5))
     13 anim

Cell In[2], line 63, in animate_convolution(x, h, y, td, taud, xlim)
     59     lines[3].set_data(ti, y_eval(ti))
     61     return lines
---> 63 return animation.FuncAnimation(fig, animate, td, interval=50, blit=True)

Cell In[2], line 51, in animate_convolution.<locals>.animate(ti)
     50 def animate(ti):
---> 51     ax[0].collections.clear()
     52     ax[0].fill_between(taud, 0, h_eval(ti, taud) *
     53                        x_eval(taud), facecolor='gray', alpha=0.3)
     55     lines[0].set_data(taud, h_eval(ti, taud))

AttributeError: 'ArtistList' object has no attribute 'clear'

Changing line 51 from ax[0].collections.clear() to ax[0].clear() fixed the compilation error, however I don't know if the result is the intended one.

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplots.html - the documentation for the command used to create the subplot of which the collection was tried to be deleted.

Thank you so much for providing this platform, it's much appreciated!

@fs446
Copy link
Member

fs446 commented May 5, 2023

Thanks for this hint, highly appreciated!

I assume that 11ecd7a fixes this issue, which was due to a matplotlib API change. The new handling might not be the most elegant, but we then can still use fill_between. New handling is: we give each fill_between one and the same label, and this can be found in a collection list, and once we found it, we can remove it. Currently, jupyter notebook seems to have problems with tornado, I had some flickering issues therefore in the animations. Downgrading to tornado 6.1 solved this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants