-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Cleanup cimports, implement bits of numpy_helper in util.pxd #21878
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# cython: profile=False | ||
cimport cython | ||
from cython cimport Py_ssize_t | ||
|
||
from cpython cimport PyFloat_Check, PyUnicode_Check | ||
|
||
from cpython.datetime cimport (PyDateTime_Check, PyDate_Check, | ||
PyDateTime_CheckExact, | ||
PyDateTime_IMPORT, | ||
timedelta, datetime, date, time) | ||
# import datetime C API | ||
PyDateTime_IMPORT | ||
|
||
|
||
cimport numpy as cnp | ||
from numpy cimport int64_t, ndarray, float64_t | ||
import numpy as np | ||
cnp.import_array() | ||
|
||
import pytz | ||
|
||
from cpython cimport PyFloat_Check, PyUnicode_Check | ||
|
||
from util cimport (is_integer_object, is_float_object, is_string_object, | ||
is_datetime64_object) | ||
|
||
from cpython.datetime cimport (PyDateTime_Check, PyDate_Check, | ||
PyDateTime_CheckExact, | ||
PyDateTime_IMPORT, | ||
timedelta, datetime, date, time) | ||
# import datetime C API | ||
PyDateTime_IMPORT | ||
|
||
|
||
from tslibs.np_datetime cimport (check_dts_bounds, | ||
pandas_datetimestruct, | ||
|
@@ -30,13 +35,6 @@ from tslibs.np_datetime import OutOfBoundsDatetime | |
|
||
from tslibs.parsing import parse_datetime_string | ||
|
||
cimport cython | ||
from cython cimport Py_ssize_t | ||
|
||
|
||
import pytz | ||
|
||
|
||
from tslibs.timedeltas cimport cast_from_unit | ||
from tslibs.timezones cimport (is_utc, is_tzlocal, is_fixed_offset, | ||
treat_tz_as_pytz, get_dst_info) | ||
|
@@ -54,7 +52,8 @@ from tslibs.timestamps cimport (create_timestamp_from_ts, | |
_NS_UPPER_BOUND, _NS_LOWER_BOUND) | ||
from tslibs.timestamps import Timestamp | ||
|
||
cdef bint PY2 = str == bytes | ||
|
||
DEF PY2 = str == bytes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should define in util.pxd maybe (future ok) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubt that works for DEF values, but not much downside. |
||
|
||
|
||
cdef inline object create_datetime_from_ts( | ||
|
@@ -556,8 +555,9 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise', | |
if len(val) == 0 or val in nat_strings: | ||
iresult[i] = NPY_NAT | ||
continue | ||
if PyUnicode_Check(val) and PY2: | ||
val = val.encode('utf-8') | ||
if PY2: | ||
if PyUnicode_Check(val): | ||
val = val.encode('utf-8') | ||
|
||
try: | ||
_string_to_dts(val, &dts, &out_local, &out_tzoffset) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,8 +334,6 @@ class _BaseOffset(object): | |
# other is not a DateOffset object | ||
return False | ||
|
||
return self._params == other._params | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this didn't break anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was unreachable; there was a compile-time warning about it. |
||
|
||
def __ne__(self, other): | ||
return not self == other | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,14 +46,14 @@ from conversion cimport tz_convert_utc_to_tzlocal | |
from frequencies cimport (get_freq_code, get_base_alias, | ||
get_to_timestamp_base, get_freq_str, | ||
get_rule_month) | ||
from parsing import parse_time_string, NAT_SENTINEL | ||
from parsing import parse_time_string | ||
from resolution import Resolution | ||
from nattype import nat_strings, NaT, iNaT | ||
from nattype cimport _nat_scalar_rules, NPY_NAT, is_null_datetimelike | ||
from offsets cimport to_offset | ||
from offsets import _Tick | ||
|
||
cdef bint PY2 = str == bytes | ||
DEF PY2 = str == bytes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
|
||
cdef extern from "period_helper.h": | ||
|
@@ -729,7 +729,7 @@ cdef object _period_strftime(int64_t value, int freq, object fmt): | |
|
||
result = result.replace(str_extra_fmts[i], repl) | ||
|
||
if PY2: | ||
IF PY2: | ||
result = result.decode('utf-8', 'ignore') | ||
|
||
return result | ||
|
@@ -1820,7 +1820,7 @@ class Period(_Period): | |
value = str(value) | ||
value = value.upper() | ||
dt, _, reso = parse_time_string(value, freq) | ||
if dt is NAT_SENTINEL: | ||
if dt is NaT: | ||
ordinal = iNaT | ||
|
||
if freq is None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prob can remove this comment (future PR ok)