MCPcopy
hub / github.com/pathwaycom/pathway / test_method_in_groupby

Function test_method_in_groupby

python/pathway/tests/test_transformers.py:1072–1111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1070
1071
1072def test_method_in_groupby():
1073 @transformer
1074 class foo_transformer:
1075 class table(ClassArg):
1076 a: int = input_attribute()
1077
1078 @method
1079 def method(self, arg) -> int:
1080 return self.a * arg
1081
1082 input = T(
1083 """
1084 a | grouper
1085 1 | 1
1086 2 | 1
1087 3 | 2
1088 4 | 2
1089 5 | 3
1090 6 | 3
1091 """,
1092 )
1093
1094 oracle = foo_transformer(input).table
1095
1096 combined = input + oracle
1097
1098 result = combined.groupby(combined.grouper).reduce(
1099 res=reducers.sum(combined.method(combined.a))
1100 )
1101 assert_table_equality_wo_index(
1102 result,
1103 T(
1104 """
1105 res
1106 5
1107 25
1108 61
1109 """,
1110 ),
1111 )

Callers

nothing calls this directly

Calls 5

TFunction · 0.90
methodMethod · 0.80
foo_transformerClass · 0.70
reduceMethod · 0.45
groupbyMethod · 0.45

Tested by

no test coverage detected