Skip to content

Commit d6553e5

Browse files
author
MomIsBestFriend
committed
Fixed tests
1 parent 8043788 commit d6553e5

File tree

4 files changed

+5
-68
lines changed

4 files changed

+5
-68
lines changed

pandas/_libs/tslibs/nattype.pyx

+3-29
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ class NaTType(_NaT):
414414
""")
415415
# _nat_methods
416416
date = _make_nat_func('date', datetime.date.__doc__)
417+
fromisocalendar = _make_nat_func(
418+
'fromisocalendar', datetime.fromisocalendar.__doc__
419+
)
417420

418421
utctimetuple = _make_error_func('utctimetuple', datetime)
419422
timetz = _make_error_func('timetz', datetime)
@@ -467,36 +470,7 @@ class NaTType(_NaT):
467470
Return a new Timestamp representing UTC day and time.
468471
"""
469472
)
470-
fromisocalendar = _make_error_func('fromisocalendar', # noqa:E128
471-
"""
472-
Timestamp.fromisocalendar(year, week, day)
473-
474-
Return a new Timestamp corresponding to the
475-
ISO calendar date specified by year, week and day.
476-
477-
Parameters
478-
----------
479-
year: int
480-
Representing a year.
481-
week : int
482-
Value between 1-53, representing a week in a year.
483-
day : int
484-
Value between 1-7, representing a day in the week.
485-
486-
Returns
487-
-------
488-
Timestamp
489473

490-
Raises
491-
------
492-
NotImplementedError
493-
If the running platform is a Python version earlier than 3.8
494-
495-
Notes
496-
-----
497-
`week` can have the value of 53, only when year is a leap year.
498-
"""
499-
)
500474
timestamp = _make_error_func('timestamp', # noqa:E128
501475
"""Return POSIX timestamp as float.""")
502476

pandas/_libs/tslibs/timestamps.pyx

-39
Original file line numberDiff line numberDiff line change
@@ -336,45 +336,6 @@ class Timestamp(_Timestamp):
336336
"""
337337
return cls(datetime.combine(date, time))
338338

339-
@classmethod
340-
def fromisocalendar(cls, year, week, day):
341-
"""
342-
Timestamp.fromisocalendar(year, week, day)
343-
344-
Return a new Timestamp corresponding to the
345-
ISO calendar date specified by year, week and day.
346-
347-
Parameters
348-
----------
349-
year: int
350-
Representing a year.
351-
week : int
352-
Value between 1-53, representing a week in a year.
353-
day : int
354-
Value between 1-7, representing a day in the week.
355-
356-
Returns
357-
-------
358-
Timestamp
359-
360-
Raises
361-
------
362-
NotImplementedError
363-
If the running platform is a Python version earlier than 3.8
364-
365-
Notes
366-
-----
367-
`week` can have the value of 53, only when year is a leap year.
368-
"""
369-
import pandas.compat as compat
370-
371-
if not compat.PY38:
372-
raise NotImplementedError(
373-
"'fromisocalendar' is not supported for versions earlier than 3.8"
374-
)
375-
376-
return cls(datetime.fromisocalendar(year, week, day))
377-
378339
def __new__(
379340
cls,
380341
object ts_input=_no_input,

pandas/tests/scalar/test_nat.py

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def test_round_nat(klass, method, freq):
123123
"dst",
124124
"fromordinal",
125125
"fromtimestamp",
126+
"fromisocalendar",
126127
"isocalendar",
127128
"strftime",
128129
"strptime",

pandas/tests/scalar/timestamp/test_timestamp.py

+1
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ def test_constructor_fromisocalendar(self):
712712
result = Timestamp.fromisocalendar(2000, 1, 1)
713713
assert result == expected_timestamp
714714
assert result == expected_stdlib
715+
assert isinstance(result, Timestamp)
715716

716717

717718
class TestTimestamp:

0 commit comments

Comments
 (0)