python/ray/data/impl/simple_block.py
def _apply_accum(
        self,
        init: AggType,
        accum: Callable[[AggType, T], AggType],
        on: KeyFn,
        ignore_nulls: bool,
    ) -> Optional[U]:
        """Helper providing null handling around applying an aggregation."""
        if on is not None and not callable(on):
            raise ValueError(
                "on must be a callable or None when aggregating on Simple blocks, but "
                f"got: {type(on)}."
            )

        if self.num_rows() == 0:
            return None

        has_data = False
        a = init
        for r in self.iter_rows():
            if on is not None:
                r = on(r)
            if r is None:
                if ignore_nulls:
                    continue
                else:
                    return None
            else:
                has_data = True
                a = accum(a, r)
        return a if has_data else None
Helper providing null handling around applying an aggregation.
Helper providing null handling around applying an aggregation.
Helper providing null handling around applying an aggregation .
def _apply_accum(
        self,
        init: AggType,
        accum: Callable[[AggType, T], AggType],
        on: KeyFn,
        ignore_nulls: bool,
    ) -> Optional[U]:
        if on is not None and not callable(on):
            raise ValueError(
                "on must be a callable or None when aggregating on Simple blocks, but "
                f"got: {type(on)}."
            )
        if self.num_rows() == 0:
            return None
        has_data = False
        a = init
        for r in self.iter_rows():
            if on is not None:
                r = on(r)
            if r is None:
                if ignore_nulls:
                    continue
                else:
                    return None
            else:
                has_data = True
                a = accum(a, r)
        return a if has_data else None
def _apply_accum ( self , init : AggType , accum : Callable [ [ AggType , T ] , AggType ] , on : KeyFn , ignore_nulls : bool , ) -> Optional [ U ] : if on is not None and not callable ( on ) : raise ValueError ( "on must be a callable or None when aggregating on Simple blocks, but " f"got: {type(on)}." ) if self . num_rows ( ) == 0 : return None has_data = False a = init for r in self . iter_rows ( ) : if on is not None : r = on ( r ) if r is None : if ignore_nulls : continue else : return None else : has_data = True a = accum ( a , r ) return a if has_data else None
Helper providing null handling around applying an aggregation.
Helper providing null handling around applying an aggregation .
"""Helper providing null handling around applying an aggregation."""
self
init
AggType
accum
Callable[[AggType, T], AggType]
on
KeyFn
ignore_nulls
bool