MCPcopy
hub / github.com/pathwaycom/pathway / test_custom_mean_stdev

Function test_custom_mean_stdev

python/pathway/tests/test_reducers.py:182–211  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180
181
182def test_custom_mean_stdev():
183 left = T(
184 """
185 pet | owner | age
186 cat | Alice | 10
187 dog | Bob | 9
188 cat | Alice | 8
189 dog | Bob | 7
190 """
191 )
192
193 left_res = left.groupby(left.pet).reduce(
194 left.pet, mean_stdev=custom_mean_stdev(pw.this.age)
195 )
196
197 left_res = left_res.with_columns(
198 mean=pw.this.mean_stdev[0], stdev=pw.this.mean_stdev[1]
199 ).without(pw.this.mean_stdev)
200
201 assert_table_equality_wo_types(
202 left_res,
203 T(
204 """
205 pet | mean | stdev
206 dog | 8 | 1
207 cat | 9 | 1
208 """,
209 id_from=["pet"],
210 ),
211 )
212
213
214class CustomProductWithAdditionAccumulator(pw.BaseCustomAccumulator):

Callers

nothing calls this directly

Calls 5

TFunction · 0.90
with_columnsMethod · 0.80
reduceMethod · 0.45
groupbyMethod · 0.45
withoutMethod · 0.45

Tested by

no test coverage detected