diff --git a/py-polars/tests/unit/operations/namespaces/list/test_pad.py b/py-polars/tests/unit/operations/namespaces/list/test_pad.py index 587fb18c8178..5eb1f2b7161d 100644 --- a/py-polars/tests/unit/operations/namespaces/list/test_pad.py +++ b/py-polars/tests/unit/operations/namespaces/list/test_pad.py @@ -18,8 +18,8 @@ def test_list_pad_start_with_expr_fill() -> None: {"a": [[1], [], [1, 2, 3]], "int": [0, 999, 2], "float": [0.0, 999, 2]} ) result = df.select( - filled_int=pl.col("a").list.pad_start(fill_value=pl.col("int"), width=3), - filled_float=pl.col("a").list.pad_start(fill_value=pl.col("float"), width=1), + filled_int=pl.col("a").list.pad_start(fill_value=pl.col("int"), length=3), + filled_float=pl.col("a").list.pad_start(fill_value=pl.col("float"), length=1), ) expected = pl.DataFrame( { @@ -53,53 +53,53 @@ def test_list_pad_start_with_expr_fill() -> None: ) def test_list_pad_start_with_lit_fill(data: Any, fill_value: Any, expect: Any) -> None: df = pl.DataFrame({"a": data}) - result = df.select(pl.col("a").list.pad_start(fill_value, width=3)) + result = df.select(pl.col("a").list.pad_start(fill_value, length=3)) expected = pl.DataFrame({"a": expect}) assert_frame_equal(result, expected) def test_list_pad_start_no_slice() -> None: df = pl.DataFrame({"a": [[1], [2, 3, 4, 5]]}) - result = df.select(pl.col("a").list.pad_start(1, width=2)) + result = df.select(pl.col("a").list.pad_start(1, length=2)) expected = pl.DataFrame( {"a": [[1, 1], [2, 3, 4, 5]]}, schema={"a": pl.List(pl.Int64)} ) assert_frame_equal(result, expected) -def test_list_pad_start_with_expr_width() -> None: - df = pl.DataFrame({"a": [[1], [], [1, 2, 3]], "width": [2, 2, 4]}) +def test_list_pad_start_with_expr_length() -> None: + df = pl.DataFrame({"a": [[1], [], [1, 2, 3]], "length": [2, 2, 4]}) result = df.select( - width_expr=pl.col("a").list.pad_start( - fill_value=999, width=pl.col("a").list.len().max() + length_expr=pl.col("a").list.pad_start( + fill_value=999, length=pl.col("a").list.len().max() ), - width_col=pl.col("a").list.pad_start(fill_value=999, width=pl.col("width")), + length_col=pl.col("a").list.pad_start(fill_value=999, length=pl.col("length")), ) expected = pl.DataFrame( { - "width_expr": [[999, 999, 1], [999, 999, 999], [1, 2, 3]], - "width_col": [[999, 1], [999, 999], [999, 1, 2, 3]], + "length_expr": [[999, 999, 1], [999, 999, 999], [1, 2, 3]], + "length_col": [[999, 1], [999, 999], [999, 1, 2, 3]], } ) assert_frame_equal(result, expected) -def test_list_pad_start_zero_width() -> None: +def test_list_pad_start_zero_length() -> None: df = pl.DataFrame({"a": [[1], [2, 3]]}) - result = df.select(pl.col("a").list.pad_start(1, width=0)) + result = df.select(pl.col("a").list.pad_start(1, length=0)) expected = pl.DataFrame({"a": [[1], [2, 3]]}, schema={"a": pl.List(pl.Int64)}) assert_frame_equal(result, expected) def test_list_pad_start_casts_to_supertype() -> None: df = pl.DataFrame({"a": [["a"], ["a", "b"]]}) - result = df.select(pl.col("a").list.pad_start(1, width=2)) + result = df.select(pl.col("a").list.pad_start(1, length=2)) expected = pl.DataFrame({"a": [["1", "a"], ["a", "b"]]}) assert_frame_equal(result, expected) with pytest.raises(SchemaError, match="failed to determine supertype"): pl.DataFrame({"a": [[]]}, schema={"a": pl.List(pl.Categorical)}).select( - pl.col("a").list.pad_start(True, width=2) + pl.col("a").list.pad_start(True, length=2) ) @@ -107,13 +107,13 @@ def test_list_pad_start_errors() -> None: df = pl.DataFrame({"a": [["a"], ["a", "b"]]}) with pytest.raises(TypeError, match="fill_value"): - df.select(pl.col("a").list.pad_start(width=2)) # type: ignore[call-arg] + df.select(pl.col("a").list.pad_start(length=2)) # type: ignore[call-arg] with pytest.raises(InvalidOperationError, match="to String not supported"): - df.select(pl.col("a").list.pad_start(timedelta(days=1), width=2)) + df.select(pl.col("a").list.pad_start(timedelta(days=1), length=2)) with pytest.raises( InvalidOperationError, match="conversion from `i32` to `u64` failed" ): - df.select(pl.col("a").list.pad_start("foo", width=-1)) + df.select(pl.col("a").list.pad_start("foo", length=-1)) @pytest.mark.parametrize( @@ -127,4 +127,4 @@ def test_list_pad_start_errors() -> None: def test_list_pad_start_unsupported_type(fill_value: Any, type: Any) -> None: df = pl.DataFrame({"a": [[], []]}, schema={"a": pl.List(type)}) with pytest.raises(InvalidOperationError, match="doesn't work on data type"): - df.select(pl.col("a").list.pad_start(fill_value, width=2)) + df.select(pl.col("a").list.pad_start(fill_value, length=2))