Skip to content

Commit e7327e7

Browse files
author
MomIsBestFriend
committed
Added testing for NAT
1 parent 56363e7 commit e7327e7

File tree

3 files changed

+6
-68
lines changed

3 files changed

+6
-68
lines changed

pandas/_libs/tslibs/nattype.pyx

+1-29
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ class NaTType(_NaT):
426426
toordinal = _make_error_func('toordinal', datetime)
427427
tzname = _make_error_func('tzname', datetime)
428428
utcoffset = _make_error_func('utcoffset', datetime)
429+
fromisocalendar = _make_error_func('fromisocalendar', datetime)
429430

430431
# ----------------------------------------------------------------------
431432
# The remaining methods have docstrings copy/pasted from the analogous
@@ -467,36 +468,7 @@ class NaTType(_NaT):
467468
Return a new Timestamp representing UTC day and time.
468469
"""
469470
)
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.
476471

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
489-
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-
)
500472
timestamp = _make_error_func('timestamp', # noqa:E128
501473
"""Return POSIX timestamp as float.""")
502474

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

+5
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",
@@ -298,6 +299,10 @@ def test_overlap_public_nat_methods(klass, expected):
298299
if klass is Timestamp and not compat.PY37:
299300
expected.remove("fromisoformat")
300301

302+
# "fromisocalendar" was introduced in 3.8
303+
if klass is Timestamp and not compat.PY38:
304+
expected.remove("fromisocalendar")
305+
301306
assert _get_overlap_public_nat_methods(klass) == expected
302307

303308

0 commit comments

Comments
 (0)