Skip to content

Commit a0784d2

Browse files
authored
REF: Remove dynamic docstrings from option methods (#57710)
* REF: Remove dynamic docstrings from option methods * Fix arguments * Reuse * Fix drop duplicate section, numpydoc valudation * Fix formatting
1 parent 038976e commit a0784d2

File tree

17 files changed

+234
-303
lines changed

17 files changed

+234
-303
lines changed

pandas/_config/config.py

Lines changed: 200 additions & 266 deletions
Large diffs are not rendered by default.

pandas/core/arrays/arrow/_arrow_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pyarrow
77

8-
from pandas._config.config import _get_option
8+
from pandas._config.config import get_option
99

1010
from pandas.errors import PerformanceWarning
1111
from pandas.util._exceptions import find_stack_level
@@ -16,7 +16,7 @@ def fallback_performancewarning(version: str | None = None) -> None:
1616
Raise a PerformanceWarning for falling back to ExtensionArray's
1717
non-pyarrow method
1818
"""
19-
if _get_option("performance_warnings"):
19+
if get_option("performance_warnings"):
2020
msg = "Falling back on a non-pyarrow code path which may decrease performance."
2121
if version is not None:
2222
msg += f" Upgrade to pyarrow >={version} to possibly suppress this warning."

pandas/core/arrays/datetimelike.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import numpy as np
2222

23-
from pandas._config.config import _get_option
23+
from pandas._config.config import get_option
2424

2525
from pandas._libs import (
2626
algos,
@@ -1336,7 +1336,7 @@ def _addsub_object_array(self, other: npt.NDArray[np.object_], op) -> np.ndarray
13361336
# If both 1D then broadcasting is unambiguous
13371337
return op(self, other[0])
13381338

1339-
if _get_option("performance_warnings"):
1339+
if get_option("performance_warnings"):
13401340
warnings.warn(
13411341
"Adding/subtracting object-dtype array to "
13421342
f"{type(self).__name__} not vectorized.",

pandas/core/arrays/datetimes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import numpy as np
1717

18-
from pandas._config.config import _get_option
18+
from pandas._config.config import get_option
1919

2020
from pandas._libs import (
2121
lib,
@@ -820,7 +820,7 @@ def _add_offset(self, offset: BaseOffset) -> Self:
820820
# "dtype[Any] | type[Any] | _SupportsDType[dtype[Any]]"
821821
res_values = res_values.view(values.dtype) # type: ignore[arg-type]
822822
except NotImplementedError:
823-
if _get_option("performance_warnings"):
823+
if get_option("performance_warnings"):
824824
warnings.warn(
825825
"Non-vectorized DateOffset being applied to Series or "
826826
"DatetimeIndex.",

pandas/core/arrays/sparse/array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import numpy as np
2020

21-
from pandas._config.config import _get_option
21+
from pandas._config.config import get_option
2222

2323
from pandas._libs import lib
2424
import pandas._libs.sparse as splib
@@ -1158,7 +1158,7 @@ def searchsorted(
11581158
side: Literal["left", "right"] = "left",
11591159
sorter: NumpySorter | None = None,
11601160
) -> npt.NDArray[np.intp] | np.intp:
1161-
if _get_option("performance_warnings"):
1161+
if get_option("performance_warnings"):
11621162
msg = "searchsorted requires high memory usage."
11631163
warnings.warn(msg, PerformanceWarning, stacklevel=find_stack_level())
11641164
v = np.asarray(v)

pandas/core/arrays/string_arrow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import numpy as np
1414

15-
from pandas._config.config import _get_option
15+
from pandas._config.config import get_option
1616

1717
from pandas._libs import (
1818
lib,
@@ -345,7 +345,7 @@ def _str_contains(
345345
self, pat, case: bool = True, flags: int = 0, na=np.nan, regex: bool = True
346346
):
347347
if flags:
348-
if _get_option("mode.performance_warnings"):
348+
if get_option("mode.performance_warnings"):
349349
fallback_performancewarning()
350350
return super()._str_contains(pat, case, flags, na, regex)
351351

@@ -406,7 +406,7 @@ def _str_replace(
406406
regex: bool = True,
407407
):
408408
if isinstance(pat, re.Pattern) or callable(repl) or not case or flags:
409-
if _get_option("mode.performance_warnings"):
409+
if get_option("mode.performance_warnings"):
410410
fallback_performancewarning()
411411
return super()._str_replace(pat, repl, n, case, flags, regex)
412412

pandas/core/computation/align.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import numpy as np
1717

18-
from pandas._config.config import _get_option
18+
from pandas._config.config import get_option
1919

2020
from pandas.errors import PerformanceWarning
2121
from pandas.util._exceptions import find_stack_level
@@ -127,7 +127,7 @@ def _align_core(terms):
127127

128128
ordm = np.log10(max(1, abs(reindexer_size - term_axis_size)))
129129
if (
130-
_get_option("performance_warnings")
130+
get_option("performance_warnings")
131131
and ordm >= 1
132132
and reindexer_size >= 10000
133133
):

pandas/core/dtypes/dtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import numpy as np
2222
import pytz
2323

24-
from pandas._config.config import _get_option
24+
from pandas._config.config import get_option
2525

2626
from pandas._libs import (
2727
lib,
@@ -2030,7 +2030,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
20302030

20312031
# np.nan isn't a singleton, so we may end up with multiple
20322032
# NaNs here, so we ignore the all NA case too.
2033-
if _get_option("performance_warnings") and (
2033+
if get_option("performance_warnings") and (
20342034
not (len(set(fill_values)) == 1 or isna(fill_values).all())
20352035
):
20362036
warnings.warn(

pandas/core/frame.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6506,15 +6506,15 @@ def drop_duplicates(
65066506
DataFrame or None
65076507
DataFrame with duplicates removed or None if ``inplace=True``.
65086508
6509-
Notes
6510-
-------
6511-
This method requires columns specified by ``subset`` to be of hashable type.
6512-
Passing unhashable columns will raise a ``TypeError``.
6513-
65146509
See Also
65156510
--------
65166511
DataFrame.value_counts: Count unique combinations of columns.
65176512
6513+
Notes
6514+
-----
6515+
This method requires columns specified by ``subset`` to be of hashable type.
6516+
Passing unhashable columns will raise a ``TypeError``.
6517+
65186518
Examples
65196519
--------
65206520
Consider dataset containing ramen rating.

pandas/core/indexes/multi.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import numpy as np
2222

2323
from pandas._config import get_option
24-
from pandas._config.config import _get_option
2524

2625
from pandas._libs import (
2726
algos as libalgos,
@@ -2380,7 +2379,7 @@ def drop( # type: ignore[override]
23802379
step = loc.step if loc.step is not None else 1
23812380
inds.extend(range(loc.start, loc.stop, step))
23822381
elif com.is_bool_indexer(loc):
2383-
if _get_option("performance_warnings") and self._lexsort_depth == 0:
2382+
if get_option("performance_warnings") and self._lexsort_depth == 0:
23842383
warnings.warn(
23852384
"dropping on a non-lexsorted multi-index "
23862385
"without a level parameter may impact performance.",
@@ -3042,7 +3041,7 @@ def _maybe_to_slice(loc):
30423041
if not follow_key:
30433042
return slice(start, stop)
30443043

3045-
if _get_option("performance_warnings"):
3044+
if get_option("performance_warnings"):
30463045
warnings.warn(
30473046
"indexing past lexsort depth may impact performance.",
30483047
PerformanceWarning,

0 commit comments

Comments
 (0)