From 1a7a48561aae1a24de74dbd02491fb886dc98b49 Mon Sep 17 00:00:00 2001 From: alexander-beedie Date: Thu, 12 Oct 2023 00:58:17 +0400 Subject: [PATCH] minor docstring update and an extra unit test --- py-polars/polars/config.py | 3 ++- py-polars/tests/unit/test_cfg.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/py-polars/polars/config.py b/py-polars/polars/config.py index 72b2aef89cc6..162e56be4d05 100644 --- a/py-polars/polars/config.py +++ b/py-polars/polars/config.py @@ -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 ----- diff --git a/py-polars/tests/unit/test_cfg.py b/py-polars/tests/unit/test_cfg.py index 515555a5d8e6..54b766e3cdaf 100644 --- a/py-polars/tests/unit/test_cfg.py +++ b/py-polars/tests/unit/test_cfg.py @@ -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]} )