Skip to content

Commit da12887

Browse files
committed
DOC: Run all doctests
1 parent f33207b commit da12887

40 files changed

+100
-100
lines changed

.github/workflows/code-checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ jobs:
5757
run: sudo apt-get update && sudo apt-get install -y libegl1 libopengl0
5858

5959
- name: Run doctests
60+
env:
61+
PANDAS_SET_MODULE_DUNDER: 0
6062
run: cd ci && ./code_checks.sh doctests
6163
if: ${{ steps.build.outcome == 'success' && always() }}
6264

pandas/_libs/interval.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ cdef class Interval(IntervalMixin):
445445
>>> interval.closed
446446
'left'
447447
"""
448-
__module__ = "pandas"
449448

450449
def __init__(self, left, right, str closed="right"):
451450
# note: it is faster to just do these checks than to use a special

pandas/_libs/missing.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ class NAType(C_NAType):
394394
True
395395
"""
396396
__module__ = "pandas.api.typing"
397-
398397
_instance = None
399398

400399
def __new__(cls, *args, **kwargs):

pandas/_libs/tslibs/nattype.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ class NaTType(_NaT):
371371
0 2023-01-01
372372
1 NaT
373373
"""
374-
375374
__module__ = "pandas.api.typing"
376375

377376
def __new__(cls):

pandas/_libs/tslibs/np_datetime.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class OutOfBoundsDatetime(ValueError):
193193
at position 0
194194
"""
195195
__module__ = "pandas.errors"
196-
pass
197196

198197

199198
class OutOfBoundsTimedelta(ValueError):
@@ -213,9 +212,8 @@ class OutOfBoundsTimedelta(ValueError):
213212
OutOfBoundsTimedelta: Cannot cast 139999 days 00:00:00
214213
to unit='ns' without overflow.
215214
"""
216-
__module__ = "pandas.errors"
217215
# Timedelta analogue to OutOfBoundsDatetime
218-
pass
216+
__module__ = "pandas.errors"
219217

220218

221219
cdef get_implementation_bounds(

pandas/_libs/tslibs/offsets.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ from pandas._libs.tslibs.ccalendar import (
4747
int_to_weekday,
4848
weekday_to_int,
4949
)
50+
from pandas.util._decorators import set_module
5051
from pandas.util._exceptions import find_stack_level
5152

5253
from pandas._libs.tslibs.ccalendar cimport (
@@ -1695,6 +1696,7 @@ class OffsetMeta(type):
16951696

16961697

16971698
# TODO: figure out a way to use a metaclass with a cdef class
1699+
@set_module("pandas")
16981700
class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
16991701
"""
17001702
Standard kind of date increment used for a date range.
@@ -1822,8 +1824,6 @@ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
18221824
>>> ts + pd.DateOffset(hour=8)
18231825
Timestamp('2017-01-01 08:10:11')
18241826
"""
1825-
__module__ = "pandas"
1826-
18271827
def __setattr__(self, name, value):
18281828
raise AttributeError("DateOffset objects are immutable.")
18291829

pandas/_libs/tslibs/period.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,12 +1626,12 @@ DIFFERENT_FREQ = ("Input has different freq={other_freq} "
16261626
"from {cls}(freq={own_freq})")
16271627

16281628

1629+
@set_module("pandas.errors")
16291630
class IncompatibleFrequency(TypeError):
16301631
"""
16311632
Raised when trying to compare or operate between Periods with different
16321633
frequencies.
16331634
"""
1634-
__module__ = "pandas.errors"
16351635
pass
16361636

16371637

pandas/core/apply.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
)
3030
from pandas.compat._optional import import_optional_dependency
3131
from pandas.errors import SpecificationError
32-
from pandas.util._decorators import cache_readonly
32+
from pandas.util._decorators import (
33+
cache_readonly,
34+
set_module,
35+
)
3336

3437
from pandas.core.dtypes.cast import is_nested_object
3538
from pandas.core.dtypes.common import (
@@ -75,6 +78,7 @@
7578
ResType: TypeAlias = dict[int, Any]
7679

7780

81+
@set_module("pandas.api.executors")
7882
class BaseExecutionEngine(abc.ABC):
7983
"""
8084
Base class for execution engines for map and apply methods.
@@ -88,8 +92,6 @@ class BaseExecutionEngine(abc.ABC):
8892
simply runs the code with the Python interpreter and pandas.
8993
"""
9094

91-
__module__ = "pandas.api.executors"
92-
9395
@staticmethod
9496
@abc.abstractmethod
9597
def map(

pandas/core/arrays/arrow/array.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
PYARROW_MIN_VERSION,
3737
)
3838
from pandas.errors import Pandas4Warning
39-
from pandas.util._decorators import doc
39+
from pandas.util._decorators import (
40+
doc,
41+
set_module,
42+
)
4043
from pandas.util._exceptions import find_stack_level
4144

4245
from pandas.core.dtypes.cast import (
@@ -241,6 +244,7 @@ def to_pyarrow_type(
241244
return None
242245

243246

247+
@set_module("pandas.arrays")
244248
class ArrowExtensionArray(
245249
OpsMixin,
246250
ExtensionArraySupportsAnyAll,
@@ -296,8 +300,6 @@ class ArrowExtensionArray(
296300
Length: 3, dtype: int64[pyarrow]
297301
""" # noqa: E501 (http link too long)
298302

299-
__module__ = "pandas.arrays"
300-
301303
_pa_array: pa.ChunkedArray
302304
_dtype: ArrowDtype
303305

pandas/core/arrays/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from pandas.errors import AbstractMethodError
3232
from pandas.util._decorators import (
3333
cache_readonly,
34+
set_module,
3435
)
3536
from pandas.util._validators import (
3637
validate_bool_kwarg,
@@ -105,6 +106,7 @@
105106
_extension_array_shared_docs: dict[str, str] = {}
106107

107108

109+
@set_module("pandas.api.extensions")
108110
class ExtensionArray:
109111
"""
110112
Abstract base class for custom 1-D array types.
@@ -256,8 +258,6 @@ class ExtensionArray:
256258
https://github.com/pandas-dev/pandas/blob/main/pandas/tests/extension/list/array.py
257259
"""
258260

259-
__module__ = "pandas.api.extensions"
260-
261261
# '_typ' is for pandas.core.dtypes.generic.ABCExtensionArray.
262262
# Don't override this.
263263
_typ = "extension"
@@ -2788,6 +2788,7 @@ def _add_logical_ops(cls) -> None:
27882788
setattr(cls, "__rxor__", cls._create_logical_method(roperator.rxor))
27892789

27902790

2791+
@set_module("pandas.api.extensions")
27912792
class ExtensionScalarOpsMixin(ExtensionOpsMixin):
27922793
"""
27932794
A mixin for defining ops on an ExtensionArray.
@@ -2814,8 +2815,6 @@ class ExtensionScalarOpsMixin(ExtensionOpsMixin):
28142815
with NumPy arrays.
28152816
"""
28162817

2817-
__module__ = "pandas.api.extensions"
2818-
28192818
@classmethod
28202819
def _create_method(cls, op, coerce_to_dtype: bool = True, result_dtype=None):
28212820
"""

0 commit comments

Comments
 (0)