Example #1
0
    def filter(self, operator):
        """
        Applies a Filter transformation on a DataSet.

        he transformation calls a FilterFunction for each element of the DataSet and retains only those element
        for which the function returns true. Elements for which the function returns false are filtered.

        :param operator: The FilterFunction that is called for each element of the DataSet.
        :return:A FilterOperator that represents the filtered DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = FilterFunction()
            operator.filter = f
        child = dict()
        child_set = OperatorSet(self._env, child)
        child[_Fields.IDENTIFIER] = _Identifier.FILTER
        child[_Fields.PARENT] = self._info
        child[_Fields.OPERATOR] = operator
        child[_Fields.META] = str(inspect.getmodule(operator)) + "|" + str(operator.__class__.__name__)
        child[_Fields.NAME] = "PythonFilter"
        child[_Fields.TYPES] = deduct_output_type(self._info)
        self._info[_Fields.CHILDREN].append(child)
        self._env._sets.append(child)
        return child_set
Example #2
0
    def filter(self, operator):
        """
        Applies a Filter transformation on a DataSet.

        he transformation calls a FilterFunction for each element of the DataSet and retains only those element
        for which the function returns true. Elements for which the function returns false are filtered.

        :param operator: The FilterFunction that is called for each element of the DataSet.
        :return:A FilterOperator that represents the filtered DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = FilterFunction()
            operator.filter = f
        child = dict()
        child_set = OperatorSet(self._env, child)
        child[_Fields.IDENTIFIER] = _Identifier.FILTER
        child[_Fields.PARENT] = self._info
        child[_Fields.OPERATOR] = operator
        child[_Fields.META] = str(inspect.getmodule(operator)) + "|" + str(
            operator.__class__.__name__)
        child[_Fields.NAME] = "PythonFilter"
        child[_Fields.TYPES] = deduct_output_type(self._info)
        self._info[_Fields.CHILDREN].append(child)
        self._env._sets.append(child)
        return child_set
Example #3
0
    def filter(self, operator):
        """
        Applies a Filter transformation on a DataSet.

        he transformation calls a FilterFunction for each element of the DataSet and retains only those element
        for which the function returns true. Elements for which the function returns false are filtered.

        :param operator: The FilterFunction that is called for each element of the DataSet.
        :return:A FilterOperator that represents the filtered DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = FilterFunction()
            operator.filter = f
        child = OperationInfo()
        child_set = OperatorSet(self._env, child)
        child.identifier = _Identifier.FILTER
        child.parent = self._info
        child.operator = operator
        child.meta = str(inspect.getmodule(operator)) + "|" + str(
            operator.__class__.__name__)
        child.name = "PythonFilter"
        child.types = deduct_output_type(self._info)
        self._info.children.append(child)
        self._env._sets.append(child)
        return child_set
Example #4
0
    def filter(self, operator):
        """
        Applies a Filter transformation on a DataSet.

        he transformation calls a FilterFunction for each element of the DataSet and retains only those element
        for which the function returns true. Elements for which the function returns false are filtered.

        :param operator: The FilterFunction that is called for each element of the DataSet.
        :return:A FilterOperator that represents the filtered DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = FilterFunction()
            operator.filter = f
        child = OperationInfo()
        child_set = OperatorSet(self._env, child)
        child.identifier = _Identifier.FILTER
        child.parent = self._info
        child.operator = operator
        child.meta = str(inspect.getmodule(operator)) + "|" + str(operator.__class__.__name__)
        child.name = "PythonFilter"
        child.types = deduct_output_type(self._info)
        self._info.children.append(child)
        self._env._sets.append(child)
        return child_set