# Input arrays with vtkPythonAlgorithm

**URL:** https://discourse.vtk.org/t/input-arrays-with-vtkpythonalgorithm/3282
**Category:** Support
**Created:** [May 12, 2020, 11:28am UTC](https://discourse.vtk.org/t/input-arrays-with-vtkpythonalgorithm/3282 "2020-05-12T11:28:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lhofmann](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@lhofmann](https://discourse.vtk.org/u/lhofmann)
#### Post date: [May 12, 2020, 11:28am UTC](https://discourse.vtk.org/t/input-arrays-with-vtkpythonalgorithm/3282/1 "2020-05-12T11:28:31Z")

</div>

Python classes derived from `VTKPythonAlgorithmBase` have the usual `SetInputArrayToProcess` method but no `GetInputArrayToProcess`. However, `GetInputArrayInformation` does exist and works just like in C++.  
Ist this done on purpose? Is there a canonical way to handle input arrays in python algorithms?

I’m currently working around this by defining my own (limited version of) `GetInputArrayToProcess`:

```python
class MyFilter(VTKPythonAlgorithmBase):
    def GetInputArrayToProcess(self, id, data_object):
        """ emulates the missing vtkAlgorithm::GetInputArrayToProcess method """
        info = self.GetInputArrayInformation(id)
        field = info.Get(vtkDataObject.FIELD_ASSOCIATION())
        name = info.Get(vtkDataObject.FIELD_NAME())
        if field == vtkDataObject.FIELD_ASSOCIATION_POINTS:
            return data_object.PointData[name]
        elif field == vtkDataObject.FIELD_ASSOCIATION_CELLS:
            return data_object.CellData[name]
        elif field == vtkDataObject.FIELD_ASSOCIATION_NONE:
            return data_object.FieldData[name]
        else: # not implemented
            return None

    def RequestData(self, request, inInfo, outInfo):
        input_data = dsa.WrapDataObject(vtkDataObject.GetData(inInfo[0], 0))
        input_array = self.GetInputArrayToProcess(0, input_data)

```
