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

Bug: nullptr arrays cause infinte recursion #306

Closed
banesullivan opened this issue Jul 11, 2019 · 0 comments
Closed

Bug: nullptr arrays cause infinte recursion #306

banesullivan opened this issue Jul 11, 2019 · 0 comments
Labels
bug Uh-oh! Something isn't working as expected. priority-high This is a fairly serious issue/feature request that needs to be addressed.

Comments

@banesullivan
Copy link
Member

banesullivan commented Jul 11, 2019

If a nullptr array is present, then PyVista goes ballistic

import pyvista as pv
import vtk

earth = vtk.vtkEarthSource()
earth.SetRadius(5380)
earth.OutlineOn()
earth.Update()
continents = pv.wrap(earth.GetOutput())

# Try to access the point arrays
continents.point_arrays

Output:

---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-15-403e4a0f4e87> in <module>
      9 
     10 # Try to access the point arrays
---> 11 continents.point_arrays

~/Documents/OpenGeoVis/Software/pyvista/pyvista/core/common.py in point_arrays(self)
    697         for i in range(narr):
    698             name = pdata.GetArrayName(i)
--> 699             self._point_arrays[name] = self._point_scalar(name)
    700 
    701         self._point_arrays.enable_callback()

~/Documents/OpenGeoVis/Software/pyvista/pyvista/core/common.py in _point_scalar(self, name)
    342         if name is None:
    343             # use active scalar array
--> 344             field, name = self.active_scalar_info
    345             if field != POINT_DATA_FIELD:
    346                 raise RuntimeError('Must specify an array to fetch.')

~/Documents/OpenGeoVis/Software/pyvista/pyvista/core/common.py in active_scalar_info(self)
     53 
     54         # rare error where scalar name isn't a valid scalar
---> 55         if name not in self.point_arrays:
     56             if name not in self.cell_arrays:
     57                 if name in self.field_arrays:

... last 3 frames repeated, from the frame below ...

~/Documents/OpenGeoVis/Software/pyvista/pyvista/core/common.py in point_arrays(self)
    697         for i in range(narr):
    698             name = pdata.GetArrayName(i)
--> 699             self._point_arrays[name] = self._point_scalar(name)
    700 
    701         self._point_arrays.enable_callback()

RecursionError: maximum recursion depth exceeded

How do I know its a nullptr issue?

print(continents.GetPointData())
vtkPointData (0x7f8a9ee428c0)
  Debug: Off
  Modified Time: 289156
  Reference Count: 2
  Registered Events: 
    Registered Observers:
      vtkObserver (0x7f8a9ee63530)
        Event: 33
        EventName: ModifiedEvent
        Command: 0x7f8a9ee90590
        Priority: 0
        Tag: 1
  Number Of Arrays: 1
  Array 0 name = nullptr
  Number Of Components: 3
  Number Of Tuples: 1028
  Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
  Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
  Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
  Scalars: (none)
  Vectors: (none)
  Normals: 
    Debug: Off
    Modified Time: 289118
    Reference Count: 2
    Registered Events: (none)
    Name: (none)
    Data type: float
    Size: 3084
    MaxId: 3083
    NumberOfComponents: 3
    Information: 0x0
    Name: (none)
    Number Of Components: 3
    Number Of Tuples: 1028
    Size: 3084
    MaxId: 3083
    LookupTable: (none)
  TCoords: (none)
  Tensors: (none)
  GlobalIds: (none)
  PedigreeIds: (none)
  EdgeFlag: (none)

Note the:

...
  Number Of Arrays: 1
  Array 0 name = nullptr
...

Immediate solution incase someone else encounters this:

import vtk
earth = vtk.vtkEarthSource()
earth.SetRadius(5380)
earth.OutlineOn()
earth.Update()
foo = pv.wrap(earth.GetOutput())

# Copy the geometries only
continents = pv.PolyData()
continents.points = foo.points.copy()
continents.lines = foo.lines.copy()
del foo
@banesullivan banesullivan added bug Uh-oh! Something isn't working as expected. priority-high This is a fairly serious issue/feature request that needs to be addressed. labels Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh-oh! Something isn't working as expected. priority-high This is a fairly serious issue/feature request that needs to be addressed.
Projects
None yet
Development

No branches or pull requests

1 participant