CERN / TIGRE

TIGRE: Tomographic Iterative GPU-based Reconstruction Toolbox
BSD 3-Clause "New" or "Revised" License
550 stars 182 forks source link

d01_CreateGeometry.py raises an AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection' #375

Closed LEECHAN96 closed 2 years ago

LEECHAN96 commented 2 years ago

Expected Behavior

Create geometry and show it

Actual Behavior

Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\matplotlib\backends\backend_qt.py", line 477, in _draw_idle self.draw() File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\matplotlib\backends\backend_agg.py", line 436, in draw self.figure.draw(self.renderer) File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\matplotlib\artist.py", line 73, in draw_wrapper result = draw(artist, renderer, *args, **kwargs) File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\matplotlib\artist.py", line 50, in draw_wrapper return draw(artist, renderer) File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\matplotlib\figure.py", line 2837, in draw mimage._draw_list_compositing_images( File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images a.draw(renderer) File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\matplotlib\artist.py", line 50, in draw_wrapper return draw(artist, renderer) File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 451, in draw for artist in sorted(collections_and_patches, File "C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 426, in do_3d_projection signature = inspect.signature(artist.do_3d_projection) AttributeError: 'Arrow3D' object has no attribute 'do_3d_projection'

Code to reproduce the problem (If applicable)

(the demo1 code)

Specifications

AnderBiguri commented 2 years ago

I heard that there are some plotting errors in new python versions and conda enviroments. I admitedly have no idea where this comes from or how to solve it!

LEECHAN96 commented 2 years ago

I heard that there are some plotting errors in new python versions and conda enviroments. I admitedly have no idea where this comes from or how to solve it!

Thank you very much for your reply, I will test other demos first.

tsadakane commented 2 years ago

FYI. In my environment,

Python matplotlib Building TIGRE d01
3.8.10 3.3.4 OK OK
3.9.12 3.4.3 OK OK
3.10.4 3.5.1 NG --
OS Windows 10 Pro 21H2
CUDA 11.6
GPU GTX 1060 6GB
MSVS 2022 (17.1.1)
Python Anaconda
AnderBiguri commented 2 years ago

So it does not build in 3.10? I heard somewhere that the way setuptools work changed at some point recently, so maybe thats the case.

I assume the Arrow3D has to do with matlplotlib.

In any case, PR #370 changes this demo for something quite nicer, however it needs some work to make it compatible with general TIGRE usage (i.e. not conda, and posibility of running it on a cluster, i.e. change the visual backed, as it does now). See discussion on #357.

I simply don't have time to test and work on that PR.

harshitAgr commented 2 years ago

I was able to solve it by putting below function in Arrow3D class in the plot_geometry.py.

  def do_3d_projection(self, renderer=None):
        from mpl_toolkits.mplot3d import proj3d
        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)
AnderBiguri commented 2 years ago

@harshitAgr Do you want to make a pull request to add this to the repo?

harshitAgr commented 2 years ago

sure, just sent it PR# 377