Skip to content

CLN: Avoiding casting #32897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ def try_parse_date_and_time(object[:] dates, object[:] times,
object[:] result

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

Expand Down Expand Up @@ -614,8 +614,8 @@ def try_parse_year_month_day(object[:] years, object[:] months,
object[:] result

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

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

n = len(years)
# Cast to avoid build warning see GH#26757
if (<Py_ssize_t>len(months) != n or <Py_ssize_t>len(days) != n or
<Py_ssize_t>len(hours) != n or <Py_ssize_t>len(minutes) != n or
<Py_ssize_t>len(seconds) != n):
# TODO(cython 3.0): Use len instead of `shape[0]`
if (
months.shape[0] != n
or days.shape[0] != n
or hours.shape[0] != n
or minutes.shape[0] != n
or seconds.shape[0] != n
):
raise ValueError('Length of all datetime components must be equal')
result = np.empty(n, dtype='O')

Expand Down