I am writing a python plugin in which I need to load time-dependent data. I noticed an issue when I pass a time step list of size 1. Instead of showing just a single time step, Paraview shows the list with the following values: [time, time + 1/9, time + 2/9, ... time + 9/9]
The problem is reproducible using this simple source class:
from paraview.util.vtkAlgorithm import smproperty, smproxy
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
@smproxy.source(label="test")
class Test(VTKPythonAlgorithmBase):
def __init__(self):
super().__init__(nInputPorts=0, nOutputPorts=1)
self.time_steps = [11, 12, 13, 14, 15]
@smproperty.doublevector(name="TimestepValues", information_only="1", si_class="vtkSITimeStepsProperty")
def GetTimestepValues(self):
return self.time_steps
def RequestInformation(self, request, inInfo, outInfo):
executive = self.GetExecutive()
outInfo = outInfo.GetInformationObject(0)
outInfo.Remove(executive.TIME_STEPS())
outInfo.Remove(executive.TIME_RANGE())
outInfo.Set(executive.TIME_STEPS(), self.time_steps, len(self.time_steps))
outInfo.Set(executive.TIME_RANGE(), [self.time_steps[0], self.time_steps[-1]], 2)
return 1
def RequestData(self, request, inInfo, outInfo):
executive = self.GetExecutive()
info = outInfo.GetInformationObject(0)
time_step = info.Get(executive.UPDATE_TIME_STEP())
print(f"Using timestep: {time_step}")
return 1
The code above works as is, without issues and correctly displays the list, as such:
However, when changing the list to a single time step, e.g: self.time_steps = [11]
Instead of only showing 11, paraview shows the following list:
This issue seems to only occur when the list of time steps only contains a single value. When looking at the information tab in Paraview, under the “Data Statistics” header, it correctly displays “# of TimeSteps 1”. Is there a problem in my implementation or is this an issue with Paraview? Thank you!