Skip to content

Commit

Permalink
Update references
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Oct 21, 2023
1 parent 564ba1c commit e65bbb7
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion py-polars/tests/unit/dataframe/test_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ def test_shift_and_fill() -> None:
"ham": ["a", "b", "c"],
}
)
result = df.shift_and_fill(fill_value=0, periods=1)
result = df.shift_and_fill(fill_value=0, n=1)
expected = pl.DataFrame(
{
"foo": [0, 1, 2],
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/datatypes/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_shift_and_fill() -> None:
[pl.col("a").cast(pl.Categorical)]
)

s = df.with_columns(pl.col("a").shift_and_fill("c", periods=1))["a"]
s = df.with_columns(pl.col("a").shift_and_fill("c", n=1))["a"]
assert s.dtype == pl.Categorical
assert s.to_list() == ["c", "a"]

Expand Down
4 changes: 2 additions & 2 deletions py-polars/tests/unit/datatypes/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ def test_supertype_timezones_4174() -> None:

# test if this runs without error
date_to_fill = df["dt_London"][0]
df.with_columns(df["dt_London"].shift_and_fill(date_to_fill, periods=1))
df.with_columns(df["dt_London"].shift_and_fill(date_to_fill, n=1))


@pytest.mark.skip(reason="from_dicts cannot yet infer timezones")
Expand All @@ -1446,7 +1446,7 @@ def test_shift_and_fill_group_logicals() -> None:
schema=["d", "s"],
)
assert df.select(
pl.col("d").shift_and_fill(pl.col("d").max(), periods=-1).over("s")
pl.col("d").shift_and_fill(pl.col("d").max(), n=-1).over("s")
).dtypes == [pl.Date]


Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/operations/map/test_map_batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_map_no_dtype_set_8531() -> None:
df = pl.DataFrame({"a": [1]})

result = df.with_columns(
pl.col("a").map_batches(lambda x: x * 2).shift_and_fill(fill_value=0, periods=0)
pl.col("a").map_batches(lambda x: x * 2).shift_and_fill(fill_value=0, n=0)
)

expected = pl.DataFrame({"a": [2]})
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/operations/rolling/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def test_rolling_slice_pushdown() -> None:
)
.agg(
[
(pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, periods=1))
(pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, n=1))
.sum()
.alias("c")
]
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/operations/test_group_by_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_group_by_dynamic_slice_pushdown() -> None:
df.sort("a")
.group_by_dynamic("a", by="b", every="2i")
.agg(
(pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, periods=1))
(pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, n=1))
.sum()
.alias("c")
)
Expand Down
8 changes: 2 additions & 6 deletions py-polars/tests/unit/operations/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,11 @@ def test_window_functions_list_types() -> None:
# as it is the same as shift.
# that's why we don't add it to the allowed types.
assert (
df.select(
pl.col("col_list").shift_and_fill(None, periods=1).alias("list_shifted")
)
df.select(pl.col("col_list").shift_and_fill(None, n=1).alias("list_shifted"))
)["list_shifted"].to_list() == [None, [1], [1], [2]]

assert (
df.select(
pl.col("col_list").shift_and_fill([], periods=1).alias("list_shifted")
)
df.select(pl.col("col_list").shift_and_fill([], n=1).alias("list_shifted"))
)["list_shifted"].to_list() == [[], [1], [1], [2]]


Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ def test_shift() -> None:
assert_series_equal(a.shift(1), pl.Series("a", [None, 1, 2]))
assert_series_equal(a.shift(-1), pl.Series("a", [2, 3, None]))
assert_series_equal(a.shift(-2), pl.Series("a", [3, None, None]))
assert_series_equal(a.shift_and_fill(10, periods=-1), pl.Series("a", [2, 3, 10]))
assert_series_equal(a.shift_and_fill(10, n=-1), pl.Series("a", [2, 3, 10]))


def test_object() -> None:
Expand Down
4 changes: 2 additions & 2 deletions py-polars/tests/unit/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ def test_shift_and_fill() -> None:

# use exprs
out = ldf.with_columns(
pl.col("a").shift_and_fill(pl.col("b").mean(), periods=-2)
pl.col("a").shift_and_fill(pl.col("b").mean(), n=-2)
).collect()
assert out["a"].null_count() == 0

# use df method
out = ldf.shift_and_fill(pl.col("b").std(), periods=2).collect()
out = ldf.shift_and_fill(pl.col("b").std(), n=2).collect()
assert out["a"].null_count() == 0


Expand Down

0 comments on commit e65bbb7

Please sign in to comment.