MCPcopy Index your code
hub / github.com/pathwaycom/pathway / count_max

Function count_max

python/pathway/tests/test_persistence.py:584–597  ·  view source on GitHub ↗
(
        state: tuple[int, int] | None, rows: list[tuple[list[int], int]]
    )

Source from the content-addressed store, hash-verified

582 # ignore below because stateful_many doesn't allow better narrower types in annotation
583 @pw.reducers.stateful_many # type: ignore
584 def count_max(
585 state: tuple[int, int] | None, rows: list[tuple[list[int], int]]
586 ) -> tuple[int, int] | None:
587 m = None
588 for row, cnt in rows:
589 value = row[0]
590 if m is None or value > m:
591 m = value
592 assert m is not None # rows are non-empty
593 if state is None:
594 state = (1, m)
595 elif state[1] < m:
596 state = (state[0] + 1, m)
597 return state
598
599 def logic(t_1: pw.Table) -> pw.Table:
600 return t_1.groupby(pw.this.a).reduce(

Callers 1

logicFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected