marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
2.03k stars 265 forks source link

test_core2 fails: 'NoneType' object has no attribute 'GetData' #1056

Open drew-parsons opened 7 months ago

drew-parsons commented 7 months ago

test_core2.py in vedo 2024.5.1 fails (with the debian build of vtk 9.1.0)

$ python3 test_core2.py 
2024-02-19 14:01:08.512 (   0.520s) [        7FD21040]       vtkXMLParser.cxx:375    ERR| vtkXMLDataParser (0x1e40440): Error parsing XML in stream at line 24, column 32, byte index 1540: not well-formed (invalid token)
2024-02-19 14:01:08.513 (   0.520s) [        7FD21040]       vtkXMLReader.cxx:521    ERR| vtkXMLUnstructuredGridReader (0x22f6980): Error parsing input file.  ReadXMLInformation aborting.
2024-02-19 14:01:08.513 (   0.520s) [        7FD21040]       vtkExecutive.cxx:752    ERR| vtkCompositeDataPipeline (0x22cbe20): Algorithm vtkXMLUnstructuredGridReader(0x22f6980) returned failure for request: vtkInformation (0x2173980)
  Debug: Off
  Modified Time: 590164
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_INFORMATION
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0

2024-02-19 14:01:08.513 (   0.521s) [        7FD21040]       vtkXMLParser.cxx:375    ERR| vtkXMLDataParser (0x1e40440): Error parsing XML in stream at line 27, column 0, byte index 1583: not well-formed (invalid token)
2024-02-19 14:01:08.513 (   0.521s) [        7FD21040]       vtkXMLReader.cxx:521    ERR| vtkXMLRectilinearGridReader (0x22fb4e0): Error parsing input file.  ReadXMLInformation aborting.
2024-02-19 14:01:08.513 (   0.521s) [        7FD21040]       vtkExecutive.cxx:752    ERR| vtkCompositeDataPipeline (0x22fbdd0): Algorithm vtkXMLRectilinearGridReader(0x22fb4e0) returned failure for request: vtkInformation (0x194c280)
  Debug: Off
  Modified Time: 590714
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_INFORMATION
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0

 -- TEST METHOD add_ids() -------------------
vedo.volume.Volume at (0x1795480)                                          
name          : Volume
filename      : /projects/.cache/vedo/embryo.tif
dimensions    : [125  80 107]
origin        : (0, 0, 0)
center        : (6450.40, 4109.53, 5514.05)
spacing       : (104.039, 104.039, 104.039)
bounds        : x=(0, 1.29e+4), y=(0, 8.22e+3), z=(0, 1.10e+4)
memory size   : 16 MB
scalar size   : 8 bytes (idtype)
scalar range  : (0.0, 1069999.0)
vedo.grids.TetMesh at (0x22e0bb0)                                          
nr. of verts  : 0
nr. of tetras : 0
bounds        : x=(1.00, -1.00), y=(1.00, -1.00), z=(1.00, -1.00)
vedo.grids.RectilinearGrid at (0x19c7270)                                  
name          : RectilinearGrid
filename      : /projects/.cache/vedo/RectilinearGrid.vtr
dimensions    : (0, 0, 0)
center        : (0, 0, 0)
bounds        : x=(0, 0), y=(0, 0), z=(0, 0)
memory size   : 2.9e-3 MB

 -- TEST METHOD average_size() -------------------
5256.014682725444
2024-02-19 14:01:08.621 (   0.628s) [        7FD21040]vtkDemandDrivenPipeline:756    ERR| vtkCompositeDataPipeline (0x1b3e740): Input for connection index 0 on input port index 0 for algorithm vtkImageToPoints(0x19624c0) is of type vtkUnstructuredGrid, but a vtkImageData is required.
/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.
  return _methods._mean(a, axis=axis, dtype=dtype,
/usr/lib/python3/dist-packages/numpy/core/_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide
  ret = ret.dtype.type(ret / rcount)
0.0
/usr/lib/python3/dist-packages/numpy/core/_methods.py:184: RuntimeWarning: invalid value encountered in divide
  ret = um.true_divide(
0.0

--- TEST METHOD bounds() -------------------
[    0.         12900.79467088     0.          8219.05466935
     0.         11028.09867027]
(1.0, -1.0, 1.0, -1.0, 1.0, -1.0)
[0. 0. 0. 0. 0. 0.]

 -- TEST METHOD cell_centers() -------------------
[[   52.01933335    52.01933335    52.01933335]
 [  156.05800005    52.01933335    52.01933335]
 [  260.09666675    52.01933335    52.01933335]
 ...
 [12640.69800413  8167.035336   10976.07933692]
 [12744.73667083  8167.035336   10976.07933692]
 [12848.77533753  8167.035336   10976.07933692]]
Traceback (most recent call last):
  File "/projects/vedo/tests/common/test_core2.py", line 31, in <module>
    print(tm.cell_centers)
          ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vedo/core.py", line 633, in cell_centers
    return utils.vtk2numpy(vcen.GetOutput().GetPoints().GetData())
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'GetData'
marcomusy commented 7 months ago

Thanks for reporting this... it's a funny thing that vtk cannot read a vtu file :( I need to check why that happens...

marcomusy commented 7 months ago

From the error messages above it looks that the reader cannot pick /projects/.cache/vedo/RectilinearGrid.vtr from https://vedo.embl.es/examples/data/RectilinearGrid.vtr

..but it works fine with /projects/.cache/vedo/embryo.tif

so i'm a bit confused as to why that happens.. i cannot reproduce the issue as vtk 9.1 is already old (!) as there's no wheels for my system (neither linux or macosx)..

drew-parsons commented 7 months ago

I see. Looks like I'll have wait until debian proves a newer release (vtk 9.3.0 is in the experimental archive).