Skip to content

Use VTKReader as dictionary

Lukas Riedel requested to merge vtkreader-as-dict into master

What does this MR do?

Split VTKDataArray off VTKReader: Make VTKReader a mapping that returns data arrays based on their names. VTKDataArray is a wrapper around the underlying VTK data array and is then used for evaluating the data.

This split makes it possible to iterate over the range of data arrays without actually knowing their names beforehand.

Before:

# array_names = [ ... ]
reader = VTKReader("vtkfile.vtu")
for name in array_names:
    reader.set_data_array(name)
    val = reader.evaluate([0.0, 0.0, 0.0])

After:

# array_names = [ ... ]
reader = VTKReader("vtkfile.vtu")
array = reader[array_names[0]]

for name, array in reader.items():
    print("Operating on array {}".format(name))
    val = array.evaluate([0.0, 0.0, 0.0])

Additionally

  • Fix a bug where python_tests were run for target system_tests.
  • Remove namespace packaging from Python setup.

Is there something that needs to be double checked?

No.

Can this MR be accepted?

  • Implemented the new Python classes
  • Updated Python unit test
  • Updated user docs
  • Pipeline passing
  • Added entry to CHANGELOG.md

Related issues

Edited by Lukas Riedel

Merge request reports