Skip to content

Commit

Permalink
DOC: Fixing EX01 - Added examples (#54277)
Browse files Browse the repository at this point in the history
Examples ExtensionArray._from_factorized, _from_sequence ...
  • Loading branch information
DeaMariaLeon authored Jul 27, 2023
1 parent 577bb72 commit 498c438
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
9 changes: 0 additions & 9 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Partially validate docstrings (EX01)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
pandas.errors.IncompatibilityWarning \
pandas.errors.OptionError \
pandas.errors.PerformanceWarning \
pandas.errors.PyperclipException \
pandas.errors.PyperclipWindowsException \
Expand All @@ -77,16 +75,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.io.stata.StataWriter.write_file \
pandas.plotting.deregister_matplotlib_converters \
pandas.plotting.register_matplotlib_converters \
pandas.api.indexers.BaseIndexer \
pandas.api.indexers.VariableOffsetWindowIndexer \
pandas.util.hash_array \
pandas.util.hash_pandas_object \
pandas_object \
pandas.api.extensions.ExtensionDtype \
pandas.api.extensions.ExtensionArray \
pandas.arrays.NumpyExtensionArray \
pandas.api.extensions.ExtensionArray._from_factorized \
pandas.api.extensions.ExtensionArray._from_sequence \
pandas.api.extensions.ExtensionArray._from_sequence_of_strings \
pandas.api.extensions.ExtensionArray._hash_pandas_object \
pandas.api.extensions.ExtensionArray._reduce \
Expand Down
6 changes: 6 additions & 0 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class OptionError(AttributeError, KeyError):
Exception raised for pandas.options.
Backwards compatible with KeyError checks.
Examples
--------
>>> pd.options.context
Traceback (most recent call last):
OptionError: No such option
"""


Expand Down
17 changes: 17 additions & 0 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ def _from_sequence(cls, scalars, *, dtype: Dtype | None = None, copy: bool = Fal
Returns
-------
ExtensionArray
Examples
--------
>>> pd.arrays.IntegerArray._from_sequence([4, 5])
<IntegerArray>
[4, 5]
Length: 2, dtype: Int64
"""
raise AbstractMethodError(cls)

Expand Down Expand Up @@ -313,6 +320,16 @@ def _from_factorized(cls, values, original):
--------
factorize : Top-level factorize method that dispatches here.
ExtensionArray.factorize : Encode the extension array as an enumerated type.
Examples
--------
>>> interv_arr = pd.arrays.IntervalArray([pd.Interval(0, 1),
... pd.Interval(1, 5), pd.Interval(1, 5)])
>>> codes, uniques = pd.factorize(interv_arr)
>>> pd.arrays.IntervalArray._from_factorized(uniques, interv_arr)
<IntervalArray>
[(0, 1], (1, 5]]
Length: 2, dtype: interval[int64, right]
"""
raise AbstractMethodError(cls)

Expand Down
1 change: 1 addition & 0 deletions scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"errors.InvalidComparison",
"errors.LossySetitemError",
"errors.NoBufferPresent",
"errors.IncompatibilityWarning",
}
PRIVATE_CLASSES = ["NDFrame", "IndexOpsMixin"]
ERROR_MSGS = {
Expand Down

0 comments on commit 498c438

Please sign in to comment.