Toolkits > com.ibm.streamsx.topology.pysamples 1.1.0 > com.ibm.streamsx.topology.pysamples.kwargs > DeltaFilter
Drops any tuple that is within a delta of the last tuple for the attribute named value.
@spl.map() class DeltaFilter(object): "Drops any tuple that is within a delta of the last tuple for the attribute named `value`." def __init__(self, delta): self.delta = delta self.empty = () self.last_value = None # Signature has **kwargs parameter which fixes the # SPL tuple parameter passing style to be dictionary def __call__(self, **tuple_): value = tuple_['value'] if self.last_value is not None: if abs(value - self.last_value) <= self.delta: self.last_value = value return None self.last_value = value # Empty tuple will cause any matching input attributes # to be carried across to the output tuple return self.empty
Required: delta
Tuple attribute values are passed by name to the Python callable using **kwargs.
Required: delta