Skip to content

Commit 8427060

Browse files
authored
DEPR: Configuration options (#49295)
1 parent 22e591f commit 8427060

File tree

3 files changed

+8
-38
lines changed

3 files changed

+8
-38
lines changed

doc/source/whatsnew/v2.0.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ Removal of prior version deprecations/changes
224224
- Enforced disallowing a string column label into ``times`` in :meth:`DataFrame.ewm` (:issue:`43265`)
225225
- Removed setting Categorical._codes directly (:issue:`41429`)
226226
- Enforced :meth:`Rolling.count` with ``min_periods=None`` to default to the size of the window (:issue:`31302`)
227+
- Enforced the ``display.max_colwidth`` option to not accept negative integers (:issue:`31569`)
228+
- Removed the ``display.column_space`` option in favor of ``df.to_string(col_space=...)`` (:issue:`47280`)
227229
- Removed the deprecated method ``mad`` from pandas classes (:issue:`11787`)
228230
- Removed the deprecated method ``tshift`` from pandas classes (:issue:`11631`)
229231

pandas/core/config_init.py

+1-28
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import os
1515
from typing import Callable
16-
import warnings
1716

1817
import pandas._config.config as cf
1918
from pandas._config.config import (
@@ -27,8 +26,6 @@
2726
is_text,
2827
)
2928

30-
from pandas.util._exceptions import find_stack_level
31-
3229
# compute
3330

3431
use_bottleneck_doc = """
@@ -363,17 +360,6 @@ def is_terminal() -> bool:
363360
float_format_doc,
364361
validator=is_one_of_factory([None, is_callable]),
365362
)
366-
367-
def _deprecate_column_space(key) -> None:
368-
warnings.warn(
369-
"column_space is deprecated and will be removed "
370-
"in a future version. Use df.to_string(col_space=...) "
371-
"instead.",
372-
FutureWarning,
373-
stacklevel=find_stack_level(),
374-
)
375-
376-
cf.register_option("column_space", 12, validator=is_int, cb=_deprecate_column_space)
377363
cf.register_option(
378364
"max_info_rows",
379365
1690785,
@@ -389,24 +375,11 @@ def _deprecate_column_space(key) -> None:
389375
)
390376
cf.register_option("max_categories", 8, pc_max_categories_doc, validator=is_int)
391377

392-
def _deprecate_negative_int_max_colwidth(key) -> None:
393-
value = cf.get_option(key)
394-
if value is not None and value < 0:
395-
warnings.warn(
396-
"Passing a negative integer is deprecated in version 1.0 and "
397-
"will not be supported in future version. Instead, use None "
398-
"to not limit the column width.",
399-
FutureWarning,
400-
stacklevel=find_stack_level(),
401-
)
402-
403378
cf.register_option(
404-
# TODO(2.0): change `validator=is_nonnegative_int` see GH#31569
405379
"max_colwidth",
406380
50,
407381
max_colwidth_doc,
408-
validator=is_instance_factory([type(None), int]),
409-
cb=_deprecate_negative_int_max_colwidth,
382+
validator=is_nonnegative_int,
410383
)
411384
if is_terminal():
412385
max_cols = 0 # automatically determine optimal number of columns

pandas/tests/io/formats/test_format.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,13 @@ def test_repr_truncation(self):
252252
with option_context("display.max_colwidth", max_len + 2):
253253
assert "..." not in repr(df)
254254

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

@@ -3483,9 +3484,3 @@ def test_filepath_or_buffer_bad_arg_raises(float_frame, method):
34833484
msg = "buf is not a file name and it has no write method"
34843485
with pytest.raises(TypeError, match=msg):
34853486
getattr(float_frame, method)(buf=object())
3486-
3487-
3488-
def test_col_space_deprecated():
3489-
# GH 7576
3490-
with tm.assert_produces_warning(FutureWarning, match="column_space is"):
3491-
set_option("display.column_space", 11)

0 commit comments

Comments
 (0)