Skip to content

Commit e5d29a4

Browse files
committed
defined them as class level attributes
1 parent 3500144 commit e5d29a4

File tree

1 file changed

+31
-36
lines changed

1 file changed

+31
-36
lines changed

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,42 +1945,6 @@ class Timedelta(_Timedelta):
19451945
_req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds",
19461946
"milliseconds", "microseconds", "nanoseconds"}
19471947

1948-
@property
1949-
def min(self):
1950-
"""
1951-
The minimum representable Timedelta.
1952-
1953-
Returns
1954-
-------
1955-
Timedelta
1956-
The minimum duration supported by Timedelta.
1957-
"""
1958-
return Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, "ns"))
1959-
1960-
@property
1961-
def max(self):
1962-
"""
1963-
The maximum representable Timedelta.
1964-
1965-
Returns
1966-
-------
1967-
Timedelta
1968-
The maximum duration supported by Timedelta.
1969-
"""
1970-
return Timedelta(np.timedelta64(np.iinfo(np.int64).max, "ns"))
1971-
1972-
@property
1973-
def resolution(self):
1974-
"""
1975-
The smallest possible difference between non-equal Timedelta objects.
1976-
1977-
Returns
1978-
-------
1979-
Timedelta
1980-
The resolution of Timedelta, i.e. Timedelta(nanoseconds=1).
1981-
"""
1982-
return Timedelta(1, unit="ns")
1983-
19841948
def __new__(cls, object value=_no_input, unit=None, **kwargs):
19851949
if value is _no_input:
19861950
if not len(kwargs):
@@ -2460,6 +2424,37 @@ class Timedelta(_Timedelta):
24602424
return div, other - div * self
24612425

24622426

2427+
Timedelta.min = Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, "ns"))
2428+
Timedelta.max = Timedelta(np.timedelta64(np.iinfo(np.int64).max, "ns"))
2429+
Timedelta.resolution = Timedelta(1, unit="ns")
2430+
2431+
Timedelta.min.__doc__ = """
2432+
The minimum representable Timedelta.
2433+
2434+
Returns
2435+
-------
2436+
Timedelta
2437+
The minimum duration supported by Timedelta.
2438+
"""
2439+
2440+
Timedelta.max.__doc__ = """
2441+
The maximum representable Timedelta.
2442+
2443+
Returns
2444+
-------
2445+
Timedelta
2446+
The maximum duration supported by Timedelta.
2447+
"""
2448+
2449+
Timedelta.resolution.__doc__ = """
2450+
The smallest possible difference between non-equal Timedelta objects.
2451+
2452+
Returns
2453+
-------
2454+
Timedelta
2455+
The resolution of Timedelta, i.e., Timedelta(nanoseconds=1).
2456+
"""
2457+
24632458
def truediv_object_array(ndarray left, ndarray right):
24642459
cdef:
24652460
ndarray[object] result = np.empty((<object>left).shape, dtype=object)

0 commit comments

Comments
 (0)