Skip to content

Commit be303fd

Browse files
committed
Address comments
1 parent 947c346 commit be303fd

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

pandas/_libs/tslibs/strptime.pyx

+27-12
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,20 @@ cdef _calc_julian_from_U_or_W(int year, int week_of_year,
638638
the week, with week_start_day representing whether the week of the year
639639
assumes the week starts on Sunday or Monday (6 or 0).
640640
641-
:param year: the year
642-
:param week_of_year: week taken from format U or W
643-
:param day_of_week: weekday
644-
:param week_starts_Mon: represent whether the week of the year
645-
assumes the week starts on Sunday or Monday (6 or 0)
646-
:returns: converted julian day.
647-
:rtype: int
641+
Parameters
642+
----------
643+
year : int
644+
the year
645+
week_of_year : int
646+
week taken from format U or W
647+
week_starts_Mon : int
648+
represents whether the week of the year
649+
assumes the week starts on Sunday or Monday (6 or 0)
650+
651+
Returns
652+
-------
653+
int
654+
converted julian day
648655
"""
649656

650657
cdef:
@@ -673,11 +680,19 @@ cdef _calc_julian_from_V(int iso_year, int iso_week, int iso_weekday):
673680
ISO weeks start on Mondays, with week 01 being the week containing 4 Jan.
674681
ISO week days range from 1 (Monday) to 7 (Sunday).
675682
676-
:param iso_year: the year taken from format %G
677-
:param iso_week: the week taken from format %V
678-
:param iso_weekday: weekday taken from format %u
679-
:returns: the iso year and the Gregorian ordinal date / julian date
680-
:rtype: (int, int)
683+
Parameters
684+
----------
685+
iso_year : int
686+
the year taken from format %G
687+
iso_week : int
688+
the week taken from format %V
689+
iso_weekday : int
690+
weekday taken from format %u
691+
692+
Returns
693+
-------
694+
(int, int)
695+
the iso year and the Gregorian ordinal date / julian date
681696
"""
682697

683698
cdef:

pandas/tests/indexes/datetimes/test_tools.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,17 @@ def test_to_datetime_iso_week_year_format(self, s, _format, dt):
291291
["ISO week directive '%V' must be used with the ISO year directive "
292292
"'%G' and a weekday directive '%A', '%a', '%w', or '%u'.", "20", "%V"]
293293
])
294-
def test_ValueError_iso_week_year(self, msg, s, _format):
294+
def test_error_iso_week_year(self, msg, s, _format):
295295
# See GH#16607
296-
if locale.getlocale() != ('zh_CN', 'UTF-8') and \
297-
locale.getlocale() != ('it_IT', 'UTF-8'):
296+
# This test checks for errors thrown when giving the wrong format
297+
# However, as discussed on PR#25541, overriding the locale
298+
# causes a different error to be thrown due to the format being
299+
# locale specific, but the test data is in english.
300+
# Thus, a hack I did was to only run this test if locale was not
301+
# overwritten. This test will need to be updated if the Ci Builds
302+
# test for locales other than these two and english.
303+
if (locale.getlocale() != ('zh_CN', 'UTF-8') and
304+
locale.getlocale() != ('it_IT', 'UTF-8')):
298305
with pytest.raises(ValueError, match=msg):
299306
to_datetime(s, format=_format)
300307

0 commit comments

Comments
 (0)