Skip to content

Commit

Permalink
fix some more bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
coastalwhite committed Jan 31, 2025
1 parent e6932e8 commit ea36e6d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/polars-core/src/series/implementations/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl SeriesTrait for SeriesWrap<TimeChunked> {
}
fn split_at(&self, offset: i64) -> (Series, Series) {
let (a, b) = self.0.split_at(offset);
(a.into_series(), b.into_series())
(a.into_time().into_series(), b.into_time().into_series())
}

fn _sum_as_f64(&self) -> f64 {
Expand Down
4 changes: 4 additions & 0 deletions py-polars/polars/testing/parametric/strategies/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,13 @@ def series(
)
)

print(values)
print(dtype)
s = Series(name=name, values=values, dtype=dtype)

# Apply masking out of values
if do_mask_out:
print("hi")
values = draw(
st.lists(
st.booleans(),
Expand All @@ -249,6 +252,7 @@ def series(

# Apply chunking
if allow_chunks and size > 1 and draw(st.booleans()):
print("hi2")
split_at = size // 2
s = s[:split_at].append(s[split_at:])

Expand Down
14 changes: 14 additions & 0 deletions py-polars/tests/unit/operations/test_merge_sorted.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import time

import pytest
from hypothesis import given

Expand Down Expand Up @@ -58,6 +60,7 @@ def test_merge_sorted_decimal_20990(precision: int) -> None:
assert_series_equal(result, expected)


@pytest.mark.may_fail_auto_streaming
def test_merge_sorted_categorical() -> None:
left = pl.Series("a", ["a", "b"], pl.Categorical()).sort().to_frame()
right = pl.Series("a", ["a", "b", "b"], pl.Categorical()).sort().to_frame()
Expand Down Expand Up @@ -139,6 +142,9 @@ def test_merge_sorted_parametric(lhs: pl.Series, rhs: pl.Series) -> None:
excluded_dtypes=[
pl.Struct, # Bug. See https://github.com/pola-rs/polars/issues/20986
pl.Binary, # Bug. See https://github.com/pola-rs/polars/issues/20988
pl.Categorical(
ordering="lexical"
), # Bug. See https://github.com/pola-rs/polars/issues/21025
],
allow_null=False, # See: https://github.com/pola-rs/polars/issues/20991
),
Expand All @@ -150,3 +156,11 @@ def test_merge_sorted_self_parametric(s: pl.Series) -> None:
append_sorted = s.append(s).sort()

assert_series_equal(merge_sorted, append_sorted)


# This was an encountered bug in the streaming engine, it was actually a bug
# with split_at.
def test_merge_time() -> None:
s = pl.Series("a", [time(0, 0)], pl.Time)
df = pl.DataFrame([s])
assert df.merge_sorted(df, "a").get_column("a").dtype == pl.Time()

0 comments on commit ea36e6d

Please sign in to comment.