|
8 | 8 | from textwrap import dedent |
9 | 9 | from types import SimpleNamespace |
10 | 10 |
|
| 11 | +import pandas as pd |
11 | 12 | import pytest |
12 | 13 |
|
13 | 14 | from graphtik import ( |
|
28 | 29 | tasks_in_parallel, |
29 | 30 | tasks_marshalled, |
30 | 31 | ) |
| 32 | +from graphtik.fnop import FnOp, Operation, as_renames, reparse_operation_data |
31 | 33 | from graphtik.modifier import dep_renamed |
32 | 34 | from graphtik.planning import yield_ops |
33 | | -from graphtik.fnop import ( |
34 | | - FnOp, |
35 | | - Operation, |
36 | | - as_renames, |
37 | | - reparse_operation_data, |
38 | | -) |
39 | 35 |
|
40 | 36 |
|
41 | 37 | @pytest.fixture(params=[None, "got"]) |
@@ -711,3 +707,17 @@ def test_conveyor_identity_fn(): |
711 | 707 | # provides=["C", "B", "A", varargs(sadasa"b", 's')] |
712 | 708 | # )() |
713 | 709 | # assert op(c=7, a=5, b=[6]) == {"A": 5, "B1": [6], "B2", "C": 7} |
| 710 | + |
| 711 | + |
| 712 | +def test_pandas_result(): |
| 713 | + ser = pd.Series([1, 2]) |
| 714 | + sol = operation(lambda: ser, name="pandas", provides="a").compute() |
| 715 | + assert (sol["a"] == ser).all() |
| 716 | + |
| 717 | + |
| 718 | +def test_pandas_input(): |
| 719 | + ser = pd.Series([1, 2]) |
| 720 | + sol = operation(fn=None, name="pandas", needs="a", provides="A")(a=ser) |
| 721 | + assert (sol["A"] == ser).all() |
| 722 | + sol = operation(fn=None, name="pandas", needs="a", provides="A").compute({"a": ser}) |
| 723 | + assert (sol["A"] == ser).all() |
0 commit comments