Skip to content
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

CLN: Remove have_pytz (gh-17251) #17266

Merged
merged 1 commit into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
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
10 changes: 3 additions & 7 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ cdef extern from "datetime.h":

cdef int64_t iNaT = util.get_nat()

try:
from dateutil.tz import tzutc as _du_utc
import pytz
UTC = pytz.utc
have_pytz = True
except ImportError:
have_pytz = False
from dateutil.tz import tzutc as _du_utc
import pytz
UTC = pytz.utc

PyDateTime_IMPORT

Expand Down
11 changes: 3 additions & 8 deletions pandas/_libs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import operator

from cpython cimport (
PyObject_RichCompareBool,
Py_EQ, Py_NE,
)
Py_EQ, Py_NE)

from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray,
NPY_INT64, NPY_DATETIME, NPY_TIMEDELTA)
Expand All @@ -24,14 +23,13 @@ cimport util, lib
from lib cimport is_null_datetimelike, is_period
from pandas._libs import tslib, lib
from pandas._libs.tslib import (Timedelta, Timestamp, iNaT,
NaT, have_pytz, _get_utcoffset)
NaT, _get_utcoffset)
from tslib cimport (
maybe_get_tz,
_is_utc,
_is_tzlocal,
_get_dst_info,
_nat_scalar_rules,
)
_nat_scalar_rules)

from pandas.tseries import offsets
from pandas.core.tools.datetimes import parse_time_string
Expand Down Expand Up @@ -610,9 +608,6 @@ cdef ndarray[int64_t] localize_dt64arr_to_period(ndarray[int64_t] stamps,
ndarray[int64_t] trans, deltas, pos
pandas_datetimestruct dts

if not have_pytz:
raise Exception('Could not find pytz module')

if _is_utc(tz):
for i in range(n):
if stamps[i] == NPY_NAT:
Expand Down
17 changes: 2 additions & 15 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4080,12 +4080,8 @@ def i8_to_pydt(int64_t i8, object tzinfo = None):
#----------------------------------------------------------------------
# time zone conversion helpers

try:
import pytz
UTC = pytz.utc
have_pytz = True
except:
have_pytz = False
import pytz
UTC = pytz.utc


@cython.boundscheck(False)
Expand All @@ -4112,9 +4108,6 @@ def tz_convert(ndarray[int64_t] vals, object tz1, object tz2):
int64_t v, offset, delta
pandas_datetimestruct dts

if not have_pytz:
import pytz

if len(vals) == 0:
return np.array([], dtype=np.int64)

Expand Down Expand Up @@ -4229,9 +4222,6 @@ def tz_convert_single(int64_t val, object tz1, object tz2):
int64_t v, offset, utc_date
pandas_datetimestruct dts

if not have_pytz:
import pytz

if val == NPY_NAT:
return val

Expand Down Expand Up @@ -4444,9 +4434,6 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,

assert is_coerce or is_raise

if not have_pytz:
raise Exception("Could not find pytz module")

if tz == UTC or tz is None:
return vals

Expand Down