Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Fix doctests #13831

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3907,9 +3907,9 @@ def estimated_size(self, unit: SizeUnit = "b") -> int | float:
... schema=[("x", pl.UInt32), ("y", pl.Float64), ("z", pl.String)],
... )
>>> df.estimated_size()
25888898
28000000
>>> df.estimated_size("mb")
24.689577102661133
26.702880859375
"""
sz = self._df.estimated_size()
return scale_bytes(sz, unit)
Expand Down
20 changes: 10 additions & 10 deletions py-polars/polars/expr/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,17 @@ def encode(self, encoding: TransferEncoding) -> Expr:
... )
>>> colors.with_columns(
... pl.col("code").bin.encode("hex").alias("code_encoded_hex"),
... )
... ) # doctest: +IGNORE_RESULT
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get these special characters right. Will check later - either improve the display of these binary types or we can change the example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.. Yeap, had the same.

I think the special characters are fine. It is more information than [binary data], but somehow doctest doesn't understand it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my terminal it looks like below, but when I copy paste it into the example the spacing is off. Not sure what is going on. Have to look a bit more closely.

Indeed this is a nice improvement over just displaying [binary data]!

image

shape: (3, 3)
┌────────┬───────────────┬──────────────────┐
│ name ┆ code ┆ code_encoded_hex │
│ --- ┆ --- ┆ --- │
│ str ┆ binary ┆ str │
╞════════╪═══════════════╪══════════════════╡
│ black ┆ [binary data] ┆ 000000 │
│ yellow ┆ [binary data] ┆ ffff00 │
│ blue ┆ [binary data] ┆ 0000ff │
└────────┴───────────────┴──────────────────┘
┌────────┬────────┬──────────────────┐
│ name ┆ code ┆ code_encoded_hex │
│ --- ┆ --- ┆ --- │
│ str ┆ binary ┆ str │
╞════════╪════════╪══════════════════╡
│ black ┆ b"" ┆ 000000 │
│ yellow ┆ b"��" ┆ ffff00 │
│ blue ┆ b"�" ┆ 0000ff │
└────────┴────────┴──────────────────┘
"""
if encoding == "hex":
return wrap_expr(self._pyexpr.bin_hex_encode())
Expand Down
14 changes: 7 additions & 7 deletions py-polars/polars/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ def binary() -> SelectorType:
>>> df = pl.DataFrame({"a": [b"hello"], "b": ["world"], "c": [b"!"], "d": [":)"]})
>>> df
shape: (1, 4)
┌───────────────┬───────┬───────────────┬─────┐
│ a ┆ b ┆ c ┆ d │
│ --- ┆ --- ┆ --- ┆ --- │
│ binary ┆ str ┆ binary ┆ str │
╞═══════════════╪═══════╪═══════════════╪═════╡
[binary data] ┆ world ┆ [binary data] ┆ :) │
└───────────────┴───────┴───────────────┴─────┘
┌──────────┬───────┬────────┬─────┐
│ a ┆ b ┆ c ┆ d │
│ --- ┆ --- ┆ --- ┆ --- │
│ binary ┆ str ┆ binary ┆ str │
╞══════════╪═══════╪════════╪═════╡
b"hello" ┆ world ┆ b"!" ┆ :) │
└──────────┴───────┴────────┴─────┘
Select binary columns and export as a dict:
Expand Down