Skip to content

Commit

Permalink
defined them as class level attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
brownl83 committed Dec 3, 2024
1 parent 3500144 commit e5d29a4
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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((<object>left).shape, dtype=object)
Expand Down

0 comments on commit e5d29a4

Please sign in to comment.