MCPcopy Index your code
hub / github.com/pathwaycom/pathway / test_py_object

Function test_py_object

python/pathway/tests/test_py_object_wrapper.py:76–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74
75
76def 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
115def test_dtypes():

Callers

nothing calls this directly

Calls 7

create_incFunction · 0.85
table_from_markdownMethod · 0.80
with_columnsMethod · 0.80
use_python_objectFunction · 0.70
filterMethod · 0.45
selectMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected