Skip to content

CLN: unreachable branch in tzconversion #34505

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 1 commit into from
May 31, 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
27 changes: 11 additions & 16 deletions pandas/_libs/tslibs/tzconversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -557,30 +557,25 @@ cdef int64_t[:] _tz_convert_dst(
ndarray[int64_t] trans
int64_t[:] deltas
int64_t v
bint tz_is_local

tz_is_local = is_tzlocal(tz)
# tz is assumed _not_ to be tzlocal; that should go
# through _tz_convert_tzlocal_utc

if not tz_is_local:
# get_dst_info cannot extract offsets from tzlocal because its
# dependent on a datetime
trans, deltas, _ = get_dst_info(tz)
if not to_utc:
# We add `offset` below instead of subtracting it
deltas = -1 * np.array(deltas, dtype='i8')
trans, deltas, _ = get_dst_info(tz)
if not to_utc:
# We add `offset` below instead of subtracting it
deltas = -1 * np.array(deltas, dtype='i8')

# Previously, this search was done pointwise to try and benefit
# from getting to skip searches for iNaTs. However, it seems call
# overhead dominates the search time so doing it once in bulk
# is substantially faster (GH#24603)
pos = trans.searchsorted(values, side='right') - 1
# Previously, this search was done pointwise to try and benefit
# from getting to skip searches for iNaTs. However, it seems call
# overhead dominates the search time so doing it once in bulk
# is substantially faster (GH#24603)
pos = trans.searchsorted(values, side='right') - 1

for i in range(n):
v = values[i]
if v == NPY_NAT:
result[i] = v
elif tz_is_local:
result[i] = _tz_convert_tzlocal_utc(v, tz, to_utc=to_utc)
else:
if pos[i] < 0:
raise ValueError('First time before start of DST info')
Expand Down