Skip to content
Snippets Groups Projects

Resolve "Collapse arrays of identical values to scalar"

Files
8
@@ -46,6 +46,15 @@ class ForEachObject(abc.ABC):
@@ -46,6 +46,15 @@ class ForEachObject(abc.ABC):
"""
"""
return self.__class__(lambda mosa: transformation(mosa, self[mosa]))
return self.__class__(lambda mosa: transformation(mosa, self[mosa]))
 
def collapsed(self):
 
"""Turn a numpy arrays containing identical elements into a scalar.
 
 
This method can be used to optimize computations when constant time series are involved.
 
"""
 
return self.transformed(lambda _, x:
 
x[0] if isinstance(x, numpy.ndarray) and numpy.all(x == x[0]) else x
 
)
 
def write(self, hdf5, dataset):
def write(self, hdf5, dataset):
"""Write values in dataset on HDF5 file.
"""Write values in dataset on HDF5 file.
Loading