def aggregate(self, function, name=None):
schema = streamsx.topology.schema.CommonSchema.Python<EOL>sl = _SourceLocation(_source_info(), "<STR_LIT>")<EOL>_name = self.topology.graph._requested_name(name, action="<STR_LIT>", func=function)<EOL>stateful = self.stream._determine_statefulness(function)<EOL>op = self.topology.graph.addOperator(self.topology.opnamespace+"<STR_LIT>", function, name=_name, sl=sl, stateful=stateful)<EOL>op.addInputPort(outputPort=self.stream.oport, window_config=self._config)<EOL>streamsx.topology.schema.StreamSchema._fnop_style(self.stream.oport.schema, op, '<STR_LIT>')<EOL>oport = op.addOutputPort(schema=schema, name=_name)<EOL>op._layout(kind='<STR_LIT>', name=_name, orig_name=name)<EOL>return Stream(self.topology, oport)._make_placeable()<EOL>
Aggregates the contents of the window when the window is
        triggered.

        Upon a window trigger, the supplied function is passed a list containing 
        the contents of the window: ``function(items)``. The order of the window 
        items in the list are the order in which they were each received by the 
        window. If the function's return value is not `None` then the result will
        be submitted as a tuple on the returned stream. If the return value is 
        `None` then no tuple submission will occur. For example, a window that 
        calculates a moving average of the last 10 tuples could be written as follows::

            win = s.last(10).trigger(1)
            moving_averages = win.aggregate(lambda tuples: sum(tuples)/len(tuples))

        .. note:: If a tumbling (:py:meth:`~Stream.batch`) window's stream
            is finite then a final aggregation is performed if the
            window is not empty. Thus ``function`` may be passed fewer tuples
            for a window sized using a count. For example a stream with 105
            tuples and a batch size of 25 tuples will perform four aggregations
            with 25 tuples each and a final aggregation of 5 tuples.

        Args:
            function: The function which aggregates the contents of the window
            name(str): The name of the returned stream. Defaults to a generated name.

        Returns: 
            Stream: A `Stream` of the returned values of the supplied function.

        .. warning::
            In Python 3.5 or later if the stream being aggregated has a
            structured schema that contains a ``blob`` type then any ``blob``
            value will not be maintained in the window. Instead its
            ``memoryview`` object will have been released. If the ``blob``
            value is required then perform a :py:meth:`map` transformation
            (without setting ``schema``) copying any required
            blob value in the tuple using ``memoryview.tobytes()``.

        .. versionadded:: 1.8
        .. versionchanged:: 1.11 Support for aggregation of streams with structured schemas.