Using a programable filter after a scalar clip will not return min/max in a table
To reproduce this error perform the following:
Manual reproduction:
- Open spcta_a.0*; Apply
- Select all cell arrays; Apply
- Perform a clip
- Select Scalar
- Select Temperature (ev)
- Select reset using current data values
- Unselect Invert; Apply
- Add a programmable filter:
- Set Output Data Set Type to vtkTable
- Select Copy Arrays
- within the script window use the following:
from paraview.vtk.numpy_interface import algorithms as np
input0 = inputs[0]
array = input0.CellData['Mass (g) - 2']
val = np.mean(array)
if type(val).__name__ == "VTKNoneArray":
val = -100
output.RowData.append(val, 'T - 1 (mean)')
val = np.std(array)
if type(val).__name__ == "VTKNoneArray":
val = -100
output.RowData.append(val, 'T - 1 (std)')
val = np.min(array)
if type(val).__name__ == "VTKNoneArray":
val = -100
output.RowData.append(val, 'T - 1 (min)')
val = np.max(array)
if type(val).__name__ == "VTKNoneArray":
val = -100
output.RowData.append(val, 'T - 1 (max)')`
- Apply
I get this error:
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "<string>", line 15, in RequestData
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 399, in min
return _global_func(MinImpl(), array, axis, controller)
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 184, in _global_func
res = impl.serial_composite(array, axis)
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 387, in serial_composite
res = _apply_func2(algs.min, array, (axis,))
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 48, in _apply_func2
res.append(func(a, *args))
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/internal_algorithms.py", line 397, in min
ans = numpy.min(narray, axis)
File "<__array_function__ internals>", line 5, in amin
File "/Snip/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2879, in amin
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
File "/Snip/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 84, in _wrapreduction
return reduction(axis=axis, out=out, **passkwargs)
File "/Snip/lib/python3.9/site-packages/numpy/core/_methods.py", line 44, in _amin
return umr_minimum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation minimum which has no identity
As stated above, I have copied the arrays from the clip to the programable filter, but the programable filter does not show the arrays that are in the clip, or a min and max that should be derived from the clip by using this filter. It does show a mean and an std value, so it should show a min and a max. It shouldn't through an error eather. This is wrong.
In each of the following scripts I have placed 'snip' for the path, so they will have to be modified to be used.
Here is another way to reproduce an error(Slightly different, but the same idea) using a script: Run this script(no_min_after_scalarclip). : no_min_after_scalarclip.py It will not show a T-1 (max) 0r a T-1(min), but will produce these errors:
ERROR: In vtkExecutive.cxx, line 741
vtkCompositeDataPipeline (0x2919f780): Algorithm vtkPVGeometryFilter (0x2917fbe0) returned failure for request: vtkInformation (0x291a0c20)
Debug: Off
Modified Time: 2830306
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA_OBJECT
FROM_OUTPUT_PORT: 0
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
ERROR: In vtkExecutive.cxx, line 741
vtkCompositeDataPipeline (0x28e04e20): Algorithm vtkPVGeometryFilter (0x28dec3e0) returned failure for request: vtkInformation (0x28e062c0)
Debug: Off
Modified Time: 2830481
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA_OBJECT
FROM_OUTPUT_PORT: 0
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "<string>", line 15, in RequestData
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 399, in min
return _global_func(MinImpl(), array, axis, controller)
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 184, in _global_func
res = impl.serial_composite(array, axis)
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 387, in serial_composite
res = _apply_func2(algs.min, array, (axis,))
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/algorithms.py", line 48, in _apply_func2
res.append(func(a, *args))
File "/Snip/lib/python3.9/site-packages/vtkmodules/numpy_interface/internal_algorithms.py", line 397, in min
ans = numpy.min(narray, axis)
File "<__array_function__ internals>", line 5, in amin
File "/Snip/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2879, in amin
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
File "/Snip/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 84, in _wrapreduction
return reduction(axis=axis, out=out, **passkwargs)
File "/Snip/lib/python3.9/site-packages/numpy/core/_methods.py", line 44, in _amin
return umr_minimum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation minimum which has no identity
**However when this script is run: [min_after_planarclip.py](/uploads/da0453a970dba5188d2cab4f63a34774/min_after_planarclip.py), it will produce the min and the max, but will give theses errors:**
ERROR: In vtkExecutive.cxx, line 741
vtkCompositeDataPipeline (0x24a7f3d0): Algorithm vtkPVGeometryFilter (0x24a5f830) returned failure for request: vtkInformation (0x24a80870)
Debug: Off
Modified Time: 2532788
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA_OBJECT
FROM_OUTPUT_PORT: 0
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
ERROR: In vtkExecutive.cxx, line 741
vtkCompositeDataPipeline (0x249fec80): Algorithm vtkPVGeometryFilter (0x249e5fe0) returned failure for request: vtkInformation (0x24a00120)
Debug: Off
Modified Time: 2532963
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA_OBJECT
FROM_OUTPUT_PORT: 0
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
This is still wrong, because it should not show theses errors at all.
I modified the pipeline for each of the examples above to include the Redistribute Data filter before the programable filter as a work-around. This should not have to be done.