Skip to content

Commit b8f1f16

Browse files
committed
Added test_midpoint_2d
1 parent 4397c64 commit b8f1f16

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test_plugin.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,28 @@ def test_vertical_weighted_mean():
196196
{"group": ["b", "a"], "weighted_mean": [6.8, 1.7999999999999998]}
197197
)
198198
assert_frame_equal(result, expected)
199+
200+
201+
def test_midpoint_2d():
202+
df = pl.DataFrame(
203+
pl.Series(
204+
"points",
205+
[
206+
[6.63, 8.35],
207+
[7.19, 4.85],
208+
[2.1, 4.21],
209+
[3.4, 6.13],
210+
[2.48, 9.26],
211+
],
212+
dtype=pl.Array(pl.Float64, 2),
213+
)
214+
)
215+
result = df.select(midpoints=mp.midpoint_2d("points", ref_point=(5.0, 5.0)))
216+
expected = pl.DataFrame(
217+
pl.Series(
218+
"midpoints",
219+
[[5.815, 6.675], [6.095, 4.925], [3.55, 4.605], [4.2, 5.565], [3.74, 7.13]],
220+
dtype=pl.Array(pl.Float64, 2),
221+
)
222+
)
223+
assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)