Operator DeltaFilter

# Operator `DeltaFilter`

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`.

## Python

    @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

## Summary

Ports
  This operator has 1 input port and 1 output port.
Windowing
  This operator does not accept any windowing configurations.
Parameters
  This operator supports 1 parameter.

  Required: delta

Metrics
  This operator does not report any metrics.

## Properties

Implementation
  C++
Threading
  `Always` - Operator always provides a single threaded execution context.

Input Ports

Ports (0)

  Tuple attribute values are passed by name to the Python callable using `**kwargs`.

  Properties
    - Optional: false
    - ControlPort: false
    - TupleMutationAllowed: false
    - WindowingMode: NonWindowed
    - WindowPunctuationInputMode: Oblivious

Output Ports

Assignments
  This operator does not allow assignments to output attributes.

Ports (0)

  Properties
    - Optional: false
    - TupleMutationAllowed: true
    - WindowPunctuationOutputMode: Preserving

Parameters

This operator supports 1 parameter.

Required: delta

`delta`
  Properties
    - Type
    - Cardinality: 1
    - Optional: false
    - ExpressionMode: AttributeFree

Libraries

`SPLPY header`
  Include Path: `../../opt/.splpy/include`
`Python libraries.`
  Command: ../../opt/.splpy/common/pyversion3.sh