NeuromatchAcademy / precourse

A repo for the pre-course work at home exercises
MIT License
613 stars 159 forks source link

Issue on page /tutorials/W0D3_LinearAlgebra/student/W0D3_Tutorial1.html #110

Closed gmatharu closed 2 years ago

gmatharu commented 2 years ago

Well its not an issue with the content itself, rather seems like a bug from matplotlib .

The issue is in Section Think! 2.1: Determing dependence, while plotting vectors in 3-D.:

    424                 """
    425                 try:
--> 426                     signature = inspect.signature(artist.do_3d_projection)
    427                     signature.bind()
    428                 # ValueError if `inspect.signature` cannot provide a signature

AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection' 

It seems like matplotlib removed the method do_3d_projection and requires us to implement it. The discussion could be found here:

https://github.com/matplotlib/matplotlib/issues/21688

I tested it in Kaggle and it works, basically you need to add this method as below to the Arrow3D class:

class Arrow3D(FancyArrowPatch):
    def __init__(self, xs, ys, zs, *args, **kwargs):
        FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
        self._verts3d = xs, ys, zs

    def draw(self, renderer):
        xs3d, ys3d, zs3d = self._verts3d
        xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
        self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))
        FancyArrowPatch.draw(self, renderer)
    def do_3d_projection(self, renderer=None):
        xs3d, ys3d, zs3d = self._verts3d
        xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M)
        self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))

        return np.min(zs)
spirosChv commented 2 years ago

resolved in https://github.com/NeuromatchAcademy/precourse/pull/42