Skip to content

DEPR: Configuration options #49295

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

Merged
merged 1 commit into from
Oct 25, 2022
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
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ Removal of prior version deprecations/changes
- Enforced disallowing a string column label into ``times`` in :meth:`DataFrame.ewm` (:issue:`43265`)
- Removed setting Categorical._codes directly (:issue:`41429`)
- Enforced :meth:`Rolling.count` with ``min_periods=None`` to default to the size of the window (:issue:`31302`)
- Enforced the ``display.max_colwidth`` option to not accept negative integers (:issue:`31569`)
- Removed the ``display.column_space`` option in favor of ``df.to_string(col_space=...)`` (:issue:`47280`)
- Removed the deprecated method ``mad`` from pandas classes (:issue:`11787`)
- Removed the deprecated method ``tshift`` from pandas classes (:issue:`11631`)

Expand Down
29 changes: 1 addition & 28 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import os
from typing import Callable
import warnings

import pandas._config.config as cf
from pandas._config.config import (
Expand All @@ -27,8 +26,6 @@
is_text,
)

from pandas.util._exceptions import find_stack_level

# compute

use_bottleneck_doc = """
Expand Down Expand Up @@ -363,17 +360,6 @@ def is_terminal() -> bool:
float_format_doc,
validator=is_one_of_factory([None, is_callable]),
)

def _deprecate_column_space(key) -> None:
warnings.warn(
"column_space is deprecated and will be removed "
"in a future version. Use df.to_string(col_space=...) "
"instead.",
FutureWarning,
stacklevel=find_stack_level(),
)

cf.register_option("column_space", 12, validator=is_int, cb=_deprecate_column_space)
cf.register_option(
"max_info_rows",
1690785,
Expand All @@ -389,24 +375,11 @@ def _deprecate_column_space(key) -> None:
)
cf.register_option("max_categories", 8, pc_max_categories_doc, validator=is_int)

def _deprecate_negative_int_max_colwidth(key) -> None:
value = cf.get_option(key)
if value is not None and value < 0:
warnings.warn(
"Passing a negative integer is deprecated in version 1.0 and "
"will not be supported in future version. Instead, use None "
"to not limit the column width.",
FutureWarning,
stacklevel=find_stack_level(),
)

cf.register_option(
# TODO(2.0): change `validator=is_nonnegative_int` see GH#31569
"max_colwidth",
50,
max_colwidth_doc,
validator=is_instance_factory([type(None), int]),
cb=_deprecate_negative_int_max_colwidth,
validator=is_nonnegative_int,
)
if is_terminal():
max_cols = 0 # automatically determine optimal number of columns
Expand Down
15 changes: 5 additions & 10 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,13 @@ def test_repr_truncation(self):
with option_context("display.max_colwidth", max_len + 2):
assert "..." not in repr(df)

def test_repr_deprecation_negative_int(self):
# TODO(2.0): remove in future version after deprecation cycle
# Non-regression test for:
def test_max_colwidth_negative_int_raises(self):
# Deprecation enforced from:
# https://github.com/pandas-dev/pandas/issues/31532
width = get_option("display.max_colwidth")
with tm.assert_produces_warning(FutureWarning):
with pytest.raises(
ValueError, match="Value must be a nonnegative integer or None"
):
set_option("display.max_colwidth", -1)
set_option("display.max_colwidth", width)

Expand Down Expand Up @@ -3483,9 +3484,3 @@ def test_filepath_or_buffer_bad_arg_raises(float_frame, method):
msg = "buf is not a file name and it has no write method"
with pytest.raises(TypeError, match=msg):
getattr(float_frame, method)(buf=object())


def test_col_space_deprecated():
# GH 7576
with tm.assert_produces_warning(FutureWarning, match="column_space is"):
set_option("display.column_space", 11)