Programmable Filter not working even for simple script

Hi,

I am an intermediate Paraview user and I am trying to learn how to use the Programmable Filter. I have read Chapter 6 in the Reference manual 6. Programmable Filter — ParaView Documentation 6.0.0 documentation . I have my own little CSV file with 20 points and tried using some example code, specifically the first example in section 6.3.1, which simply adds midpoints between all the existing points.

I import the CSV and apply a TableToPoints filter. I can see the points rendered as spheres from this filter in the viewer so I know the data has been loaded in properly. Then, I add a Programmable Filter and I copy and paste the few lines of code into the Script section. Nothing happens. I don’t get any errors or any new output of any kind.

Code from Section 6.3.1:

# 'inputs' is set to an array with data objects produced by inputs to
# this filter.

# Get the first input.
input0 = inputs[0]

# compute a value.
dataArray = input0.PointData["V"] / 2.0

# To access cell data, you can use input0.CellData.

# 'output' is a variable set to the output dataset.
output.PointData.append(dataArray, "V_half")

I have a hunch that I am missing something bigger like Paraview is missing a package or something. I even tried uninstalling and reinstalling Paraview on my system but it didn’t fix the problem.

Ultimately, I want to connect the points in my CSV into a line which is why I started down the path of Programmable filters in the first place. Based on other information I have read the only reasonable way to connect multiple points with lines is programmatically.

Looking forward to any help anyone has to offer. Thanks!

Please share your data.

Does your data have a point data array named “V”? If not, change that name to one available in your dataset.

In ParaView 5.13.3 I’m seeing that if I apply the code you supplied to a simple Plane Source, which produces “Normals” and “TextureCoordinates” point data arrays, nothing gets computed but also no errors are reported in the Output Messages window.

In fact, a peculiar thing happens. dataArray is assigned a value of type paraview.vtk.numpy_interface.dataset_adapter.VTKNoneArray rather than throwing an exception, which is probably what you are expecting. When you set this kind of array as a new data array with output.PointData.append(), it appears to be silently ignored.

A workaround for this quietness is to explicitly check for VTKNoneArray being returned when accessing a point data array. It’s a little ugly, but that would look like:

import paraview.vtk.numpy_interface.dataset_adapter
dataArray = input0.PointData["V"]
if type(dataArray) == paraview.vtk.numpy_interface.dataset_adapter.VTKNoneArray:
  print("Could not find array")