Skip to content

Commit 418b26a

Browse files
authored
CLN: Avoiding casting (#32897)
1 parent 60269d9 commit 418b26a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pandas/_libs/tslibs/parsing.pyx

+12-8
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ def try_parse_date_and_time(object[:] dates, object[:] times,
577577
object[:] result
578578

579579
n = len(dates)
580-
# Cast to avoid build warning see GH#26757
581-
if <Py_ssize_t>len(times) != n:
580+
# TODO(cython 3.0): Use len instead of `shape[0]`
581+
if times.shape[0] != n:
582582
raise ValueError('Length of dates and times must be equal')
583583
result = np.empty(n, dtype='O')
584584

@@ -614,8 +614,8 @@ def try_parse_year_month_day(object[:] years, object[:] months,
614614
object[:] result
615615

616616
n = len(years)
617-
# Cast to avoid build warning see GH#26757
618-
if <Py_ssize_t>len(months) != n or <Py_ssize_t>len(days) != n:
617+
# TODO(cython 3.0): Use len instead of `shape[0]`
618+
if months.shape[0] != n or days.shape[0] != n:
619619
raise ValueError('Length of years/months/days must all be equal')
620620
result = np.empty(n, dtype='O')
621621

@@ -640,10 +640,14 @@ def try_parse_datetime_components(object[:] years,
640640
double micros
641641

642642
n = len(years)
643-
# Cast to avoid build warning see GH#26757
644-
if (<Py_ssize_t>len(months) != n or <Py_ssize_t>len(days) != n or
645-
<Py_ssize_t>len(hours) != n or <Py_ssize_t>len(minutes) != n or
646-
<Py_ssize_t>len(seconds) != n):
643+
# TODO(cython 3.0): Use len instead of `shape[0]`
644+
if (
645+
months.shape[0] != n
646+
or days.shape[0] != n
647+
or hours.shape[0] != n
648+
or minutes.shape[0] != n
649+
or seconds.shape[0] != n
650+
):
647651
raise ValueError('Length of all datetime components must be equal')
648652
result = np.empty(n, dtype='O')
649653

0 commit comments

Comments
 (0)