Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Mar 22, 2024
1 parent 1f10faa commit d0bd429
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion crates/polars-plan/src/dsl/function_expr/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,11 @@ pub(super) fn get(s: &mut [Series]) -> PolarsResult<Option<Series>> {
if let Some(index) = index {
ca.lst_get(index).map(Some)
} else {
Ok(Some(Series::full_null(ca.name(), ca.len(), &ca.inner_dtype())))
Ok(Some(Series::full_null(
ca.name(),
ca.len(),
&ca.inner_dtype(),
)))
}
},
len if len == ca.len() => {
Expand Down
6 changes: 3 additions & 3 deletions py-polars/tests/unit/namespaces/array/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def test_array_get() -> None:
assert_series_equal(out, expected)

# Null index literal.
out = s.arr.get(None)
expected = pl.Series("a", [None, None, None], dtype=pl.Int64)
assert_series_equal(out, expected)
out_df = s.to_frame().select(pl.col.a.arr.get(pl.lit(None)))
expected_df = pl.Series("a", [None, None, None], dtype=pl.Int64).to_frame()
assert_frame_equal(out_df, expected_df)

# Out-of-bounds index literal.
out = s.arr.get(100)
Expand Down
8 changes: 4 additions & 4 deletions py-polars/tests/unit/namespaces/list/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def test_list_arr_get() -> None:
assert_series_equal(out, expected)
out = pl.select(pl.lit(a).list.last()).to_series()
assert_series_equal(out, expected)

# Out of bounds index.
out = a.list.get(3)
expected = pl.Series("a", [None, None, 9])
assert_series_equal(out, expected)

# Null index.
out = a.list.get(None)
expected = pl.Series("a", [None, None, None], dtype=pl.Int64)
assert_series_equal(out, expected)
out_df = a.to_frame().select(pl.col.a.list.get(pl.lit(None)))
expected_df = pl.Series("a", [None, None, None], dtype=pl.Int64).to_frame()
assert_frame_equal(out_df, expected_df)

a = pl.Series("a", [[1, 2, 3], [4, 5], [6, 7, 8, 9]])
out = a.list.get(-3)
Expand Down

0 comments on commit d0bd429

Please sign in to comment.