()
| 74 | |
| 75 | |
| 76 | def test_py_object(): |
| 77 | @pw.udf |
| 78 | def create_inc(a: int) -> pw.PyObjectWrapper: |
| 79 | return pw.PyObjectWrapper( |
| 80 | Inc(a, pd.DataFrame({"x": [1, 2, 3], "y": [a, a, a]})) |
| 81 | ) |
| 82 | |
| 83 | t = pw.debug.table_from_markdown( |
| 84 | """ |
| 85 | a | instance |
| 86 | 1 | 0 |
| 87 | 2 | 2 |
| 88 | 3 | 0 |
| 89 | 4 | 2 |
| 90 | """ |
| 91 | ) |
| 92 | |
| 93 | z = t.filter(pw.this.a > 2) |
| 94 | t = t.with_columns(inc=create_inc(pw.this.a)) |
| 95 | |
| 96 | @pw.udf |
| 97 | def use_python_object(a: pw.PyObjectWrapper, x: int) -> int: |
| 98 | return a.value.add(x) |
| 99 | |
| 100 | res = t.join( |
| 101 | z, left_instance=pw.left.instance, right_instance=pw.right.instance |
| 102 | ).select(res=use_python_object(pw.left.inc, pw.right.a)) |
| 103 | expected = pw.debug.table_from_markdown( |
| 104 | """ |
| 105 | res |
| 106 | 4 |
| 107 | 6 |
| 108 | 6 |
| 109 | 8 |
| 110 | """ |
| 111 | ) |
| 112 | assert_table_equality_wo_index(res, expected) |
| 113 | |
| 114 | |
| 115 | def test_dtypes(): |
nothing calls this directly
no test coverage detected