Register a unary aggregate function (mean)
()
| 329 | |
| 330 | @pytest.fixture(scope="session") |
| 331 | def unary_agg_func_fixture(): |
| 332 | """ |
| 333 | Register a unary aggregate function (mean) |
| 334 | """ |
| 335 | from pyarrow import compute as pc |
| 336 | import numpy as np |
| 337 | |
| 338 | def func(ctx, x): |
| 339 | return pa.scalar(np.nanmean(x)) |
| 340 | |
| 341 | func_name = "mean_udf" |
| 342 | func_doc = {"summary": "y=avg(x)", |
| 343 | "description": "find mean of x"} |
| 344 | |
| 345 | pc.register_aggregate_function(func, |
| 346 | func_name, |
| 347 | func_doc, |
| 348 | { |
| 349 | "x": pa.float64(), |
| 350 | }, |
| 351 | pa.float64() |
| 352 | ) |
| 353 | return func, func_name |
| 354 | |
| 355 | |
| 356 | @pytest.fixture(scope="session") |
nothing calls this directly
no outgoing calls
no test coverage detected