Register a unary aggregate function
()
| 355 | |
| 356 | @pytest.fixture(scope="session") |
| 357 | def varargs_agg_func_fixture(): |
| 358 | """ |
| 359 | Register a unary aggregate function |
| 360 | """ |
| 361 | from pyarrow import compute as pc |
| 362 | import numpy as np |
| 363 | |
| 364 | def func(ctx, *args): |
| 365 | sum = 0.0 |
| 366 | for arg in args: |
| 367 | sum += np.nanmean(arg) |
| 368 | return pa.scalar(sum) |
| 369 | |
| 370 | func_name = "sum_mean" |
| 371 | func_doc = {"summary": "Varargs aggregate", |
| 372 | "description": "Varargs aggregate"} |
| 373 | |
| 374 | pc.register_aggregate_function(func, |
| 375 | func_name, |
| 376 | func_doc, |
| 377 | { |
| 378 | "x": pa.int64(), |
| 379 | "y": pa.float64() |
| 380 | }, |
| 381 | pa.float64() |
| 382 | ) |
| 383 | return func, func_name |
nothing calls this directly
no outgoing calls
no test coverage detected