From 1bd123a2a22f44207c869ba6da0f706f083a0297 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 12:06:27 -0800 Subject: [PATCH 01/30] DOC: Fix PR02 errors in Timedelta attributes (min, max, resolution) docstrings --- ci/code_checks.sh | 6 ------ pandas/_libs/tslibs/timedeltas.pyx | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index f23481b3da3a2..872b215b54571 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -73,12 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Period.freq GL08" \ -i "pandas.Period.ordinal GL08" \ -i "pandas.RangeIndex.from_range PR01,SA01" \ - -i "pandas.Timedelta.max PR02" \ - -i "pandas.Timedelta.min PR02" \ - -i "pandas.Timedelta.resolution PR02" \ - -i "pandas.Timestamp.max PR02" \ - -i "pandas.Timestamp.min PR02" \ - -i "pandas.Timestamp.resolution PR02" \ -i "pandas.Timestamp.tzinfo GL08" \ -i "pandas.arrays.ArrowExtensionArray PR07,SA01" \ -i "pandas.arrays.IntervalArray.length SA01" \ diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e320aca04683c..e373ba77c5538 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1894,6 +1894,18 @@ class Timedelta(_Timedelta): Values for construction in compat with datetime.timedelta. Numpy ints and floats will be coerced to python ints and floats. + Attributes + ---------- + min : Timedelta + The minimum representable `Timedelta`, corresponding to the smallest + duration supported. + max : Timedelta + The maximum representable `Timedelta`, corresponding to the largest + duration supported. + resolution : Timedelta + The smallest possible difference between non-equal `Timedelta` objects, + i.e., `Timedelta(nanoseconds=1)`. + See Also -------- Timestamp : Represents a single timestamp in time. @@ -1932,6 +1944,10 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} + + Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns')) + Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns')) + Timedelta.resolution = Timedelta(1, unit='ns') def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: From d7ba6ad487b1382ec3451a569b6bb78ce4930788 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 12:12:23 -0800 Subject: [PATCH 02/30] White space error --- pandas/_libs/tslibs/timedeltas.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e373ba77c5538..ade54e5a6b945 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1894,7 +1894,7 @@ class Timedelta(_Timedelta): Values for construction in compat with datetime.timedelta. Numpy ints and floats will be coerced to python ints and floats. - Attributes + Attributes ---------- min : Timedelta The minimum representable `Timedelta`, corresponding to the smallest From 5e9d8d3e72f806aac2124fddf229ea69d954ba3e Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 12:16:07 -0800 Subject: [PATCH 03/30] White space error --- pandas/_libs/tslibs/timedeltas.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index ade54e5a6b945..b87e67a704888 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1905,7 +1905,7 @@ class Timedelta(_Timedelta): resolution : Timedelta The smallest possible difference between non-equal `Timedelta` objects, i.e., `Timedelta(nanoseconds=1)`. - + See Also -------- Timestamp : Represents a single timestamp in time. @@ -1944,7 +1944,7 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} - + Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns')) Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns')) Timedelta.resolution = Timedelta(1, unit='ns') From f086358b2796999d853c8fc5f1a9d300d8d5ddc3 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 12:27:40 -0800 Subject: [PATCH 04/30] removed --- pandas/_libs/tslibs/timedeltas.pyx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index b87e67a704888..e5940c2d38c1f 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1945,10 +1945,6 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} - Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns')) - Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns')) - Timedelta.resolution = Timedelta(1, unit='ns') - def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: if not len(kwargs): From 5c6878f495d3a345895232ea77c3b7191abfdb4c Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 14:15:44 -0800 Subject: [PATCH 05/30] assigned new docstrings to address unknown parameter --- pandas/_libs/tslibs/timedeltas.pyx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e5940c2d38c1f..fc5d95eded4ba 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -2423,6 +2423,32 @@ class Timedelta(_Timedelta): div = other // self return div, other - div * self +Timedelta.min.__doc__ = """ +The minimum representable Timedelta. + +Returns +------- +Timedelta + The minimum duration supported by Timedelta. +""" + +Timedelta.max.__doc__ = """ +The maximum representable Timedelta. + +Returns +------- +Timedelta + The maximum duration supported by Timedelta. +""" + +Timedelta.resolution.__doc__ = """ +The smallest possible difference between non-equal Timedelta objects. + +Returns +------- +Timedelta + The resolution of Timedelta, i.e., Timedelta(nanoseconds=1). +""" def truediv_object_array(ndarray left, ndarray right): cdef: From c26c5045953504aaf8e1310251ab5ab1f926c557 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 14:21:04 -0800 Subject: [PATCH 06/30] that didn't work --- pandas/_libs/tslibs/timedeltas.pyx | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index fc5d95eded4ba..e5940c2d38c1f 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -2423,32 +2423,6 @@ class Timedelta(_Timedelta): div = other // self return div, other - div * self -Timedelta.min.__doc__ = """ -The minimum representable Timedelta. - -Returns -------- -Timedelta - The minimum duration supported by Timedelta. -""" - -Timedelta.max.__doc__ = """ -The maximum representable Timedelta. - -Returns -------- -Timedelta - The maximum duration supported by Timedelta. -""" - -Timedelta.resolution.__doc__ = """ -The smallest possible difference between non-equal Timedelta objects. - -Returns -------- -Timedelta - The resolution of Timedelta, i.e., Timedelta(nanoseconds=1). -""" def truediv_object_array(ndarray left, ndarray right): cdef: From b04921dcbb190564dbe08e1c600e3c3a9d8b4770 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 14:26:30 -0800 Subject: [PATCH 07/30] added min, max, resolution as property --- pandas/_libs/tslibs/timedeltas.pyx | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e5940c2d38c1f..ae41a076c6726 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1945,6 +1945,42 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} + @property + def min(self): + """ + The minimum representable Timedelta. + + Returns + ------- + Timedelta + The minimum duration supported by Timedelta. + """ + return Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns')) + + @property + def max(self): + """ + The maximum representable Timedelta. + + Returns + ------- + Timedelta + The maximum duration supported by Timedelta. + """ + return Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns')) + + @property + def resolution(self): + """ + The smallest possible difference between non-equal Timedelta objects. + + Returns + ------- + Timedelta + The resolution of Timedelta, i.e. Timedelta(nanoseconds=1). + """ + return Timedelta(1, unit='ns') + def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: if not len(kwargs): From 3971071022531e2b13d63384b29befe2098015d2 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 14:31:09 -0800 Subject: [PATCH 08/30] fixed white space --- pandas/_libs/tslibs/timedeltas.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index ae41a076c6726..d0754805d5461 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1949,7 +1949,7 @@ class Timedelta(_Timedelta): def min(self): """ The minimum representable Timedelta. - + Returns ------- Timedelta @@ -1961,7 +1961,7 @@ class Timedelta(_Timedelta): def max(self): """ The maximum representable Timedelta. - + Returns ------- Timedelta @@ -1973,7 +1973,7 @@ class Timedelta(_Timedelta): def resolution(self): """ The smallest possible difference between non-equal Timedelta objects. - + Returns ------- Timedelta From 3500144b22cf6a6234a84612d56c1bf2da4a0f22 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 14:35:01 -0800 Subject: [PATCH 09/30] fixed double quote --- pandas/_libs/tslibs/timedeltas.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index d0754805d5461..99f177a082019 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1955,7 +1955,7 @@ class Timedelta(_Timedelta): Timedelta The minimum duration supported by Timedelta. """ - return Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns')) + return Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, "ns")) @property def max(self): @@ -1967,7 +1967,7 @@ class Timedelta(_Timedelta): Timedelta The maximum duration supported by Timedelta. """ - return Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns')) + return Timedelta(np.timedelta64(np.iinfo(np.int64).max, "ns")) @property def resolution(self): @@ -1979,7 +1979,7 @@ class Timedelta(_Timedelta): Timedelta The resolution of Timedelta, i.e. Timedelta(nanoseconds=1). """ - return Timedelta(1, unit='ns') + return Timedelta(1, unit="ns") def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: From e5d29a4c04aa0b697e3131d2630d6050be6373d6 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 14:57:39 -0800 Subject: [PATCH 10/30] defined them as class level attributes --- pandas/_libs/tslibs/timedeltas.pyx | 67 ++++++++++++++---------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 99f177a082019..73842929d9e36 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1945,42 +1945,6 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} - @property - def min(self): - """ - The minimum representable Timedelta. - - Returns - ------- - Timedelta - The minimum duration supported by Timedelta. - """ - return Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, "ns")) - - @property - def max(self): - """ - The maximum representable Timedelta. - - Returns - ------- - Timedelta - The maximum duration supported by Timedelta. - """ - return Timedelta(np.timedelta64(np.iinfo(np.int64).max, "ns")) - - @property - def resolution(self): - """ - The smallest possible difference between non-equal Timedelta objects. - - Returns - ------- - Timedelta - The resolution of Timedelta, i.e. Timedelta(nanoseconds=1). - """ - return Timedelta(1, unit="ns") - def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: if not len(kwargs): @@ -2460,6 +2424,37 @@ class Timedelta(_Timedelta): return div, other - div * self +Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, "ns")) +Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, "ns")) +Timedelta.resolution = Timedelta(1, unit="ns") + +Timedelta.min.__doc__ = """ +The minimum representable Timedelta. + +Returns +------- +Timedelta + The minimum duration supported by Timedelta. +""" + +Timedelta.max.__doc__ = """ +The maximum representable Timedelta. + +Returns +------- +Timedelta + The maximum duration supported by Timedelta. +""" + +Timedelta.resolution.__doc__ = """ +The smallest possible difference between non-equal Timedelta objects. + +Returns +------- +Timedelta + The resolution of Timedelta, i.e., Timedelta(nanoseconds=1). +""" + def truediv_object_array(ndarray left, ndarray right): cdef: ndarray[object] result = np.empty((left).shape, dtype=object) From f382ef579eac0ef3cda8ed037d345d70e633cf4d Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 15:00:05 -0800 Subject: [PATCH 11/30] fix lint line space issue --- pandas/_libs/tslibs/timedeltas.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 73842929d9e36..48bdf8aa0c621 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -2455,6 +2455,7 @@ Timedelta The resolution of Timedelta, i.e., Timedelta(nanoseconds=1). """ + def truediv_object_array(ndarray left, ndarray right): cdef: ndarray[object] result = np.empty((left).shape, dtype=object) From c7a8c8e87ee31a153d06d953cd9399aa1fb2b5b6 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 15:12:47 -0800 Subject: [PATCH 12/30] reverted back to old implmention to try again --- pandas/_libs/tslibs/timedeltas.pyx | 36 ++++-------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 48bdf8aa0c621..b8df234fbe666 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1944,6 +1944,10 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} + + Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns')) + Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns')) + Timedelta.resolution = Timedelta(1, unit='ns') def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: @@ -2424,38 +2428,6 @@ class Timedelta(_Timedelta): return div, other - div * self -Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, "ns")) -Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, "ns")) -Timedelta.resolution = Timedelta(1, unit="ns") - -Timedelta.min.__doc__ = """ -The minimum representable Timedelta. - -Returns -------- -Timedelta - The minimum duration supported by Timedelta. -""" - -Timedelta.max.__doc__ = """ -The maximum representable Timedelta. - -Returns -------- -Timedelta - The maximum duration supported by Timedelta. -""" - -Timedelta.resolution.__doc__ = """ -The smallest possible difference between non-equal Timedelta objects. - -Returns -------- -Timedelta - The resolution of Timedelta, i.e., Timedelta(nanoseconds=1). -""" - - def truediv_object_array(ndarray left, ndarray right): cdef: ndarray[object] result = np.empty((left).shape, dtype=object) From b6271bb78e938663a5e47d075911be4912b7c258 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 15:20:04 -0800 Subject: [PATCH 13/30] reverted back to old implmention to try again --- pandas/_libs/tslibs/timedeltas.pyx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index b8df234fbe666..e5940c2d38c1f 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1944,10 +1944,6 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} - - Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns')) - Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns')) - Timedelta.resolution = Timedelta(1, unit='ns') def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: From 5c480ca57e769c3540464c38181d0934a6d7d819 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 16:00:18 -0800 Subject: [PATCH 14/30] trying to override docstring to avoid unknown paramter error --- pandas/_libs/tslibs/timedeltas.pyx | 53 ++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e5940c2d38c1f..20aac4f7a8823 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1899,12 +1899,28 @@ class Timedelta(_Timedelta): min : Timedelta The minimum representable `Timedelta`, corresponding to the smallest duration supported. + + See Also + -------- + Timedelta.max : The maximum representable `Timedelta`. + Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. + max : Timedelta The maximum representable `Timedelta`, corresponding to the largest duration supported. + + See Also + -------- + Timedelta.min : The minimum representable `Timedelta`. + Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. + resolution : Timedelta - The smallest possible difference between non-equal `Timedelta` objects, - i.e., `Timedelta(nanoseconds=1)`. + The smallest possible difference between non-equal `Timedelta` objects. + + See Also + -------- + Timedelta.min : The minimum representable `Timedelta`. + Timedelta.max : The maximum representable `Timedelta`. See Also -------- @@ -1942,6 +1958,39 @@ class Timedelta(_Timedelta): We see that either way we get the same result """ + min = _Timedelta.min + max = _Timedelta.max + resolution = _Timedelta.resolution + + min.__doc__ = """ + The minimum representable `Timedelta`, corresponding to the smallest + duration supported. + + See Also + -------- + Timedelta.max : The maximum representable `Timedelta`. + Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. + """ + + max.__doc__ = """ + The maximum representable `Timedelta`, corresponding to the largest + duration supported. + + See Also + -------- + Timedelta.min : The minimum representable `Timedelta`. + Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. + """ + + resolution.__doc__ = """ + The smallest possible difference between non-equal `Timedelta` objects. + + See Also + -------- + Timedelta.min : The minimum representable `Timedelta`. + Timedelta.max : The maximum representable `Timedelta`. + """ + _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} From 2ae820426a0d0d1c9cba21abb80efc66378aa213 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 16:02:09 -0800 Subject: [PATCH 15/30] added back in remove timestamp code checks --- ci/code_checks.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 872b215b54571..9b464714cdf56 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -73,6 +73,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Period.freq GL08" \ -i "pandas.Period.ordinal GL08" \ -i "pandas.RangeIndex.from_range PR01,SA01" \ + -i "pandas.Timestamp.max PR02" \ + -i "pandas.Timestamp.min PR02" \ + -i "pandas.Timestamp.resolution PR02" \ -i "pandas.Timestamp.tzinfo GL08" \ -i "pandas.arrays.ArrowExtensionArray PR07,SA01" \ -i "pandas.arrays.IntervalArray.length SA01" \ From a4f6cbc8e6e1324cf0364ff7c556ef7a371d1b60 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 16:10:38 -0800 Subject: [PATCH 16/30] removed over ride doc --- pandas/_libs/tslibs/timedeltas.pyx | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 20aac4f7a8823..78ce5c6cf9b71 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1962,35 +1962,6 @@ class Timedelta(_Timedelta): max = _Timedelta.max resolution = _Timedelta.resolution - min.__doc__ = """ - The minimum representable `Timedelta`, corresponding to the smallest - duration supported. - - See Also - -------- - Timedelta.max : The maximum representable `Timedelta`. - Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. - """ - - max.__doc__ = """ - The maximum representable `Timedelta`, corresponding to the largest - duration supported. - - See Also - -------- - Timedelta.min : The minimum representable `Timedelta`. - Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. - """ - - resolution.__doc__ = """ - The smallest possible difference between non-equal `Timedelta` objects. - - See Also - -------- - Timedelta.min : The minimum representable `Timedelta`. - Timedelta.max : The maximum representable `Timedelta`. - """ - _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} From 958085c4d61ea2e3f8c53224e4225ebf050e00eb Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 16:14:25 -0800 Subject: [PATCH 17/30] fixed line to long --- pandas/_libs/tslibs/timedeltas.pyx | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 78ce5c6cf9b71..55acb4919bfd5 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1900,28 +1900,13 @@ class Timedelta(_Timedelta): The minimum representable `Timedelta`, corresponding to the smallest duration supported. - See Also - -------- - Timedelta.max : The maximum representable `Timedelta`. - Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. - max : Timedelta The maximum representable `Timedelta`, corresponding to the largest duration supported. - See Also - -------- - Timedelta.min : The minimum representable `Timedelta`. - Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. - resolution : Timedelta The smallest possible difference between non-equal `Timedelta` objects. - See Also - -------- - Timedelta.min : The minimum representable `Timedelta`. - Timedelta.max : The maximum representable `Timedelta`. - See Also -------- Timestamp : Represents a single timestamp in time. From 0c401f11ffc10b5ffb0395e1ae246f88fa657b46 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 16:21:27 -0800 Subject: [PATCH 18/30] removed min, max, res call --- pandas/_libs/tslibs/timedeltas.pyx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 55acb4919bfd5..961e62749d0f6 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1943,10 +1943,6 @@ class Timedelta(_Timedelta): We see that either way we get the same result """ - min = _Timedelta.min - max = _Timedelta.max - resolution = _Timedelta.resolution - _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} From d1b924a7781ac859c0b11698fbf946e4bfa6b0dc Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 16:47:26 -0800 Subject: [PATCH 19/30] added see also to min, max, resolution --- pandas/_libs/tslibs/timedeltas.pyx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 961e62749d0f6..dcb6f5b5a61d3 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1900,13 +1900,28 @@ class Timedelta(_Timedelta): The minimum representable `Timedelta`, corresponding to the smallest duration supported. + See Also + -------- + Timedelta.max : The maximum representable `Timedelta`. + Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. + max : Timedelta The maximum representable `Timedelta`, corresponding to the largest duration supported. + See Also + -------- + Timedelta.min : The minimum representable `Timedelta`. + Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. + resolution : Timedelta The smallest possible difference between non-equal `Timedelta` objects. + See Also + -------- + Timedelta.min : The minimum representable `Timedelta`. + Timedelta.max : The maximum representable `Timedelta`. + See Also -------- Timestamp : Represents a single timestamp in time. From d7e169acfcecec8b14594ce2edfd2d0464cb45cb Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 17:07:12 -0800 Subject: [PATCH 20/30] added alias in timedeltas.py --- pandas/_libs/tslibs/timedeltas.pyx | 15 --------------- pandas/core/tools/timedeltas.py | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index dcb6f5b5a61d3..961e62749d0f6 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1900,28 +1900,13 @@ class Timedelta(_Timedelta): The minimum representable `Timedelta`, corresponding to the smallest duration supported. - See Also - -------- - Timedelta.max : The maximum representable `Timedelta`. - Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. - max : Timedelta The maximum representable `Timedelta`, corresponding to the largest duration supported. - See Also - -------- - Timedelta.min : The minimum representable `Timedelta`. - Timedelta.resolution : The smallest possible difference between non-equal `Timedelta` objects. - resolution : Timedelta The smallest possible difference between non-equal `Timedelta` objects. - See Also - -------- - Timedelta.min : The minimum representable `Timedelta`. - Timedelta.max : The maximum representable `Timedelta`. - See Also -------- Timestamp : Represents a single timestamp in time. diff --git a/pandas/core/tools/timedeltas.py b/pandas/core/tools/timedeltas.py index 8d82a5c213910..1ad525969dec3 100644 --- a/pandas/core/tools/timedeltas.py +++ b/pandas/core/tools/timedeltas.py @@ -18,7 +18,7 @@ NaTType, ) from pandas._libs.tslibs.timedeltas import ( - Timedelta, + Timedelta as _Timedelta, disallow_ambiguous_unit, parse_timedelta_unit, ) From f2ebb002294a44f8b9781ebee66f643b96b05af0 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Tue, 3 Dec 2024 17:19:45 -0800 Subject: [PATCH 21/30] removed alias in timedeltas.py --- pandas/core/tools/timedeltas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/tools/timedeltas.py b/pandas/core/tools/timedeltas.py index 1ad525969dec3..8d82a5c213910 100644 --- a/pandas/core/tools/timedeltas.py +++ b/pandas/core/tools/timedeltas.py @@ -18,7 +18,7 @@ NaTType, ) from pandas._libs.tslibs.timedeltas import ( - Timedelta as _Timedelta, + Timedelta, disallow_ambiguous_unit, parse_timedelta_unit, ) From 59785d7f7db54892bd644b927e2c8a45449718e0 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 10:55:21 -0800 Subject: [PATCH 22/30] moved attributes to cdef class _Timedelta --- pandas/_libs/tslibs/timedeltas.pyx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 961e62749d0f6..13073dfcec3ad 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1031,6 +1031,19 @@ cdef class _Timedelta(timedelta): # int64_t _d, _h, _m, _s, _ms, _us, _ns # NPY_DATETIMEUNIT _reso + Attributes + ---------- + min : Timedelta + The minimum representable `Timedelta`, corresponding to the smallest + duration supported. + + max : Timedelta + The maximum representable `Timedelta`, corresponding to the largest + duration supported. + + resolution : Timedelta + The smallest possible difference between non-equal `Timedelta` objects. + # higher than np.ndarray and np.matrix __array_priority__ = 100 min = MinMaxReso("min") @@ -1894,19 +1907,6 @@ class Timedelta(_Timedelta): Values for construction in compat with datetime.timedelta. Numpy ints and floats will be coerced to python ints and floats. - Attributes - ---------- - min : Timedelta - The minimum representable `Timedelta`, corresponding to the smallest - duration supported. - - max : Timedelta - The maximum representable `Timedelta`, corresponding to the largest - duration supported. - - resolution : Timedelta - The smallest possible difference between non-equal `Timedelta` objects. - See Also -------- Timestamp : Represents a single timestamp in time. From 5e0f541df243936af6033498c908e8e098fe3265 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 11:17:05 -0800 Subject: [PATCH 23/30] trying again with different format --- pandas/_libs/tslibs/timedeltas.pyx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 13073dfcec3ad..26c28811b1d31 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1031,18 +1031,12 @@ cdef class _Timedelta(timedelta): # int64_t _d, _h, _m, _s, _ms, _us, _ns # NPY_DATETIMEUNIT _reso - Attributes - ---------- - min : Timedelta - The minimum representable `Timedelta`, corresponding to the smallest - duration supported. - - max : Timedelta - The maximum representable `Timedelta`, corresponding to the largest - duration supported. - - resolution : Timedelta - The smallest possible difference between non-equal `Timedelta` objects. + """ + Attributes: + min (Timedelta): Minimum allowable value for Timedelta. + max (Timedelta): Maximum allowable value for Timedelta. + resolution (Timedelta): Resolution of the Timedelta. + """ # higher than np.ndarray and np.matrix __array_priority__ = 100 From 8a60f009bad1ecd713da2f2865ec04b7f0e10e30 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 11:51:29 -0800 Subject: [PATCH 24/30] moved attributes back to Timedelta, set as read only --- pandas/_libs/tslibs/timedeltas.pyx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 26c28811b1d31..12bad00a6e712 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1031,13 +1031,6 @@ cdef class _Timedelta(timedelta): # int64_t _d, _h, _m, _s, _ms, _us, _ns # NPY_DATETIMEUNIT _reso - """ - Attributes: - min (Timedelta): Minimum allowable value for Timedelta. - max (Timedelta): Maximum allowable value for Timedelta. - resolution (Timedelta): Resolution of the Timedelta. - """ - # higher than np.ndarray and np.matrix __array_priority__ = 100 min = MinMaxReso("min") @@ -1901,6 +1894,17 @@ class Timedelta(_Timedelta): Values for construction in compat with datetime.timedelta. Numpy ints and floats will be coerced to python ints and floats. + Attributes + ---------- + min : Timedelta, readonly + The minimum representable `Timedelta`, corresponding to the smallest + duration supported. + max : Timedelta, readonly + The maximum representable `Timedelta`, corresponding to the largest + duration supported. + resolution : Timedelta, readonly + The smallest possible difference between non-equal `Timedelta` objects. + See Also -------- Timestamp : Represents a single timestamp in time. @@ -1940,6 +1944,10 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} + min = MinMaxReso("min") + max = MinMaxReso("max") + resolution = MinMaxReso("resolution") + def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: if not len(kwargs): From 2140fc1e28da966fbd2a2492234fba92fb844d35 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 12:26:06 -0800 Subject: [PATCH 25/30] added inline docstring to enforce that min,max,reso are constants not methods --- pandas/_libs/tslibs/timedeltas.pyx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 12bad00a6e712..d47d663792060 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1939,14 +1939,32 @@ class Timedelta(_Timedelta): Timedelta('1 days 00:00:00') We see that either way we get the same result + + Accessing the smallest and largest Timedelta values: + + >>> pd.Timedelta.min + Timedelta('-106751 days +00:12:44.000000') + + >>> pd.Timedelta.max + Timedelta('106751 days 23:47:16.854775807') + + Checking the resolution of a Timedelta object: + + >>> pd.Timedelta.resolution + Timedelta('0 days 00:00:00.000000001') """ _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} min = MinMaxReso("min") + """Timedelta: The minimum representable value.""" + max = MinMaxReso("max") + """Timedelta: The maximum representable value.""" + resolution = MinMaxReso("resolution") + """Timedelta: The smallest representable increment.""" def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: From 45de848f483d5488b07bda658a3d959be39e57f9 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 12:33:45 -0800 Subject: [PATCH 26/30] fix ponitless string error --- pandas/_libs/tslibs/timedeltas.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index d47d663792060..fd3048030455f 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1957,14 +1957,14 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} - min = MinMaxReso("min") - """Timedelta: The minimum representable value.""" + min = MinMaxReso("min") + # Timedelta: The smallest representable duration. max = MinMaxReso("max") - """Timedelta: The maximum representable value.""" + # Timedelta: The largest representable duration. resolution = MinMaxReso("resolution") - """Timedelta: The smallest representable increment.""" + # Timedelta: The smallest increment between distinct durations. def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: From 074962554ccccef759ff40a942ee31fe8ba0866c Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 12:35:45 -0800 Subject: [PATCH 27/30] white space --- pandas/_libs/tslibs/timedeltas.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index fd3048030455f..294e87eec3e0a 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1957,7 +1957,7 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} - min = MinMaxReso("min") + min = MinMaxReso("min") # Timedelta: The smallest representable duration. max = MinMaxReso("max") From 4d0ce2ac6e76976a26787d9d310fdb760d64633e Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 12:55:37 -0800 Subject: [PATCH 28/30] explicityly setting the _doc_ attribute --- pandas/_libs/tslibs/timedeltas.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 294e87eec3e0a..7e87592339732 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1958,13 +1958,13 @@ class Timedelta(_Timedelta): "milliseconds", "microseconds", "nanoseconds"} min = MinMaxReso("min") - # Timedelta: The smallest representable duration. + min.__doc__ = "Timedelta: The minimum representable value." max = MinMaxReso("max") - # Timedelta: The largest representable duration. + max.__doc__ = "Timedelta: The maximum representable value." resolution = MinMaxReso("resolution") - # Timedelta: The smallest increment between distinct durations. + resolution.__doc__ = "Timedelta: The smallest representable increment." def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: From 27efa516652a9ebf12c9cbe8e6dc93dbac728f5f Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 13:24:40 -0800 Subject: [PATCH 29/30] assign descriptors within the class --- pandas/_libs/tslibs/timedeltas.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 7e87592339732..520170f7bae7c 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1943,7 +1943,7 @@ class Timedelta(_Timedelta): Accessing the smallest and largest Timedelta values: >>> pd.Timedelta.min - Timedelta('-106751 days +00:12:44.000000') + Timedelta('-106752 days +00:12:43.145224193') >>> pd.Timedelta.max Timedelta('106751 days 23:47:16.854775807') From 2f4d35bcd340f460bd892fd80d8abd16b61c49b6 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Wed, 4 Dec 2024 13:24:52 -0800 Subject: [PATCH 30/30] assign descriptors within the class --- pandas/_libs/tslibs/timedeltas.pyx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 520170f7bae7c..2bfed0c608ff4 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1957,15 +1957,6 @@ class Timedelta(_Timedelta): _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"} - min = MinMaxReso("min") - min.__doc__ = "Timedelta: The minimum representable value." - - max = MinMaxReso("max") - max.__doc__ = "Timedelta: The maximum representable value." - - resolution = MinMaxReso("resolution") - resolution.__doc__ = "Timedelta: The smallest representable increment." - def __new__(cls, object value=_no_input, unit=None, **kwargs): if value is _no_input: if not len(kwargs): @@ -2110,6 +2101,10 @@ class Timedelta(_Timedelta): return _timedelta_from_value_and_reso(cls, value, NPY_FR_ns) + min = MinMaxReso("min") + max = MinMaxReso("max") + resolution = MinMaxReso("resolution") + def __setstate__(self, state): if len(state) == 1: # older pickle, only supported nanosecond