From 242d8dea53af1d2dcad00dff673c5fc7a7fd7e99 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 22 Sep 2020 17:59:19 -0700 Subject: [PATCH 1/6] docstring fixups, closes #26982 --- pandas/_libs/tslibs/offsets.pyx | 36 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 161e5f4e54f51..a78de3eace98c 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -219,7 +219,9 @@ cdef _wrap_timedelta_result(result): cdef _get_calendar(weekmask, holidays, calendar): - """Generate busdaycalendar""" + """ + Generate busdaycalendar + """ if isinstance(calendar, np.busdaycalendar): if not holidays: holidays = tuple(calendar.holidays) @@ -659,14 +661,18 @@ cdef class BaseOffset: return nint def __setstate__(self, state): - """Reconstruct an instance from a pickled state""" + """ + Reconstruct an instance from a pickled state + """ self.n = state.pop("n") self.normalize = state.pop("normalize") self._cache = state.pop("_cache", {}) # At this point we expect state to be empty def __getstate__(self): - """Return a pickleable state""" + """ + Return a pickleable state + """ state = {} state["n"] = self.n state["normalize"] = self.normalize @@ -971,7 +977,9 @@ cdef class RelativeDeltaOffset(BaseOffset): object.__setattr__(self, key, val) def __getstate__(self): - """Return a pickleable state""" + """ + Return a pickleable state + """ # RelativeDeltaOffset (technically DateOffset) is the only non-cdef # class, so the only one with __dict__ state = self.__dict__.copy() @@ -980,7 +988,9 @@ cdef class RelativeDeltaOffset(BaseOffset): return state def __setstate__(self, state): - """Reconstruct an instance from a pickled state""" + """ + Reconstruct an instance from a pickled state + """ if "offset" in state: # Older (<0.22.0) versions have offset attribute instead of _offset @@ -3604,7 +3614,9 @@ def shift_day(other: datetime, days: int) -> datetime: cdef inline int year_add_months(npy_datetimestruct dts, int months) nogil: - """new year number after shifting npy_datetimestruct number of months""" + """ + New year number after shifting npy_datetimestruct number of months. + """ return dts.year + (dts.month + months - 1) // 12 @@ -3702,7 +3714,9 @@ cdef inline void _shift_months(const int64_t[:] dtindex, Py_ssize_t count, int months, str day_opt) nogil: - """See shift_months.__doc__""" + """ + See shift_months.__doc__ + """ cdef: Py_ssize_t i int months_to_roll @@ -3734,7 +3748,9 @@ cdef inline void _shift_quarters(const int64_t[:] dtindex, int q1start_month, str day_opt, int modby) nogil: - """See shift_quarters.__doc__""" + """ + See shift_quarters.__doc__ + """ cdef: Py_ssize_t i int months_since, n @@ -3990,7 +4006,9 @@ cdef inline int _roll_qtrday(npy_datetimestruct* dts, int n, int months_since, str day_opt) nogil except? -1: - """See roll_qtrday.__doc__""" + """ + See roll_qtrday.__doc__ + """ if n > 0: if months_since < 0 or (months_since == 0 and From 35118c37d66ca8bf67c8eb566a68ffde92459ab0 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 22 Sep 2020 18:04:19 -0700 Subject: [PATCH 2/6] update RangeIndex docstring, closes #22373 --- pandas/core/indexes/range.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 684691501de5c..4dffda2605ef7 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -53,10 +53,12 @@ class RangeIndex(Int64Index): If int and "stop" is not given, interpreted as "stop" instead. stop : int (default: 0) step : int (default: 1) - name : object, optional - Name to be stored in the index. + dtype : np.int64 + Unused, accepted for homogeneity with other index types. copy : bool, default False Unused, accepted for homogeneity with other index types. + name : object, optional + Name to be stored in the index. Attributes ---------- From 36bfbc6fcb6ad74d86e8329347895373646eaffc Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 23 Sep 2020 16:19:56 -0700 Subject: [PATCH 3/6] CLN: misc --- pandas/_libs/interval.pyx | 2 +- pandas/_libs/tslibs/timestamps.pyx | 4 ++-- scripts/validate_rst_title_capitalization.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/interval.pyx b/pandas/_libs/interval.pyx index f8bcbcfb158b5..dff28d6d1024a 100644 --- a/pandas/_libs/interval.pyx +++ b/pandas/_libs/interval.pyx @@ -434,7 +434,7 @@ cdef class Interval(IntervalMixin): self.left // y, self.right // y, closed=self.closed) return NotImplemented - def overlaps(self, other): + def overlaps(self, other: "Interval") -> bool: """ Check whether two Interval objects overlap. diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index a01ef98b83693..78f7b2150f720 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -503,7 +503,7 @@ cdef class _Timestamp(ABCTimestamp): Returns ------- - string + str """ return self._get_date_name_field("day_name", locale) @@ -518,7 +518,7 @@ cdef class _Timestamp(ABCTimestamp): Returns ------- - string + str """ return self._get_date_name_field("month_name", locale) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index b654e27737359..c5f3701cc3c3f 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Validate that the titles in the rst files follow the proper capitalization convention. From 00a291c43ec6f9942e13daa4b14cfab9887f6aa2 Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 24 Sep 2020 09:12:56 -0700 Subject: [PATCH 4/6] CLN: update Makefil --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b915d8840cd8d..cddcc787e1dc2 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ -.PHONY : develop build clean clean_pyc doc lint-diff black +.PHONY : develop build clean clean_pyc doc lint-diff black check all: develop clean: - -python setup.py clean + -python3 setup.py clean clean_pyc: -find . -name '*.py[co]' -exec rm {} \; build: clean_pyc - python setup.py build_ext --inplace + python3 setup.py build_ext --inplace lint-diff: git diff upstream/master --name-only -- "*.py" | xargs flake8 @@ -18,13 +18,13 @@ black: black . develop: build - python -m pip install --no-build-isolation -e . + python3 -m pip install --no-build-isolation -e . doc: -rm -rf doc/build doc/source/generated cd doc; \ - python make.py clean; \ - python make.py html + python3 make.py clean; \ + python3 make.py html check: python3 scripts/validate_unwanted_patterns.py \ From a4e096551bc3d657c4f9dd96d7e4c0516842171d Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 24 Sep 2020 09:59:43 -0700 Subject: [PATCH 5/6] update nat docstrings to match --- pandas/_libs/interval.pyx | 2 +- pandas/_libs/tslibs/nattype.pyx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/interval.pyx b/pandas/_libs/interval.pyx index dff28d6d1024a..f8bcbcfb158b5 100644 --- a/pandas/_libs/interval.pyx +++ b/pandas/_libs/interval.pyx @@ -434,7 +434,7 @@ cdef class Interval(IntervalMixin): self.left // y, self.right // y, closed=self.closed) return NotImplemented - def overlaps(self, other: "Interval") -> bool: + def overlaps(self, other): """ Check whether two Interval objects overlap. diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index e346a14b531c5..3a628f997e5d6 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -392,7 +392,7 @@ class NaTType(_NaT): Returns ------- - string + str """, ) day_name = _make_nan_func( @@ -407,7 +407,7 @@ class NaTType(_NaT): Returns ------- - string + str """, ) # _nat_methods From ec1b32dbac3040731c2ee25ca0468884aadca233 Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 27 Sep 2020 11:29:42 -0700 Subject: [PATCH 6/6] revert controversial --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index cddcc787e1dc2..b915d8840cd8d 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ -.PHONY : develop build clean clean_pyc doc lint-diff black check +.PHONY : develop build clean clean_pyc doc lint-diff black all: develop clean: - -python3 setup.py clean + -python setup.py clean clean_pyc: -find . -name '*.py[co]' -exec rm {} \; build: clean_pyc - python3 setup.py build_ext --inplace + python setup.py build_ext --inplace lint-diff: git diff upstream/master --name-only -- "*.py" | xargs flake8 @@ -18,13 +18,13 @@ black: black . develop: build - python3 -m pip install --no-build-isolation -e . + python -m pip install --no-build-isolation -e . doc: -rm -rf doc/build doc/source/generated cd doc; \ - python3 make.py clean; \ - python3 make.py html + python make.py clean; \ + python make.py html check: python3 scripts/validate_unwanted_patterns.py \