Skip to content

Commit

Permalink
minor docstring update and an extra unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Oct 11, 2023
1 parent fcc18d8 commit 1a7a485
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion py-polars/polars/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ def set_float_precision(cls, precision: int | None = None) -> type[Config]:
Parameters
----------
precision : int
Number of decimal places to display
Number of decimal places to display; set to ``None`` to revert to the
default/standard behaviour.
Notes
-----
Expand Down
14 changes: 14 additions & 0 deletions py-polars/tests/unit/test_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,20 @@ def test_numeric_right_alignment() -> None:
"│ 3.333000 ┆ 6.000000 ┆ 9.000000 │\n"
"└──────────┴──────────┴──────────┘"
)
with pl.Config(float_precision=None):
assert (
str(df) == "shape: (3, 3)\n"
"┌───────┬─────┬─────┐\n"
"│ a ┆ b ┆ c │\n"
"│ --- ┆ --- ┆ --- │\n"
"│ f64 ┆ f64 ┆ f64 │\n"
"╞═══════╪═════╪═════╡\n"
"│ 1.1 ┆ 4.0 ┆ 7.0 │\n"
"│ 2.22 ┆ 5.0 ┆ 8.0 │\n"
"│ 3.333 ┆ 6.0 ┆ 9.0 │\n"
"└───────┴─────┴─────┘"
)

df = pl.DataFrame(
{"a": [1.1, 22.2, 3.33], "b": [444, 55.5, 6.6], "c": [77.7, 8888, 9.9999]}
)
Expand Down

0 comments on commit 1a7a485

Please sign in to comment.