Skip to content

Commit

Permalink
some last fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
coastalwhite committed Dec 13, 2024
1 parent 8aec80e commit 2544334
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 1 addition & 2 deletions py-polars/polars/_utils/construction/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
issue_warning,
parse_version,
)
from polars._utils.wrap import wrap_df, wrap_s
from polars.datatypes import (
N_INFER_DEFAULT,
Categorical,
Expand Down Expand Up @@ -62,7 +61,7 @@
if TYPE_CHECKING:
from collections.abc import Iterable, MutableMapping

from polars import DataFrame, Expr, Series
from polars import DataFrame, Series
from polars._typing import (
Orientation,
PolarsDataType,
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/interop/test_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ def test_arrow_roundtrip_lex_cat_20288() -> None:
assert dt.ordering == "lexical"


def test_from_arrow_string_cache_20271():
def test_from_arrow_string_cache_20271() -> None:
with pl.StringCache():
s = pl.Series("a", ["A", "B", "C"], pl.Categorical)
df = pl.from_arrow(
Expand Down
21 changes: 13 additions & 8 deletions py-polars/tests/unit/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2684,14 +2684,19 @@ def test_parquet_roundtrip_lex_cat_20288() -> None:
assert dt.ordering == "lexical"


def test_from_parquet_string_cache_20271():
def test_from_parquet_string_cache_20271() -> None:
with pl.StringCache():
f = io.BytesIO()
s = pl.Series("a", ["A", "B", "C"], pl.Categorical)
df = pl.from_arrow(
pa.table({"b": pa.DictionaryArray.from_arrays([0, 1], ["D", "E"])})
df = pl.Series("b", ["D", "E"], pl.Categorical).to_frame()
df.write_parquet(f)
f.seek(0)
df = pl.read_parquet(f)

assert_series_equal(
s.to_physical(), pl.Series("a", [0, 1, 2]), check_dtypes=False
)
assert_series_equal(df.to_series(), pl.Series("b", ["D", "E"], pl.Categorical))
assert_series_equal(
df.to_series().to_physical(), pl.Series("b", [3, 4]), check_dtypes=False
)
print(s)
print(s.to_physical())
print()
print(df.to_series())
print(df.to_series().to_physical())

0 comments on commit 2544334

Please sign in to comment.