8000 CLN: use float64_t consistently instead of double, double_t by jbrockmendel · Pull Request #23583 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

CLN: use float64_t consistently instead of double, double_t #23583

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 19 commits into from
Nov 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
standardize iNaT-->NPY_NAT
  • Loading branch information
jbrockmendel committed Nov 8, 2018
commit d46d516b8d85d03cc6089906a7bd55cdb34d795b
10 changes: 5 additions & 5 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cdef float64_t FP_ERR = 1e-13

cdef float64_t NaN = <float64_t>np.NaN

cdef int64_t iNaT = get_nat()
cdef int64_t NPY_NAT = get_nat()

tiebreakers = {
'average': TIEBREAK_AVERAGE,
Expand Down Expand Up @@ -810,23 +810,23 @@ def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike):
n = len(arr)

if n == 1:
if arr[0] != arr[0] or (timelike and <int64_t>arr[0] == iNaT):
if arr[0] != arr[0] or (timelike and <int64_t>arr[0] == NPY_NAT):
# single value is NaN
return False, False, True
else:
return True, True, True
elif n < 2:
return True, True, True

if timelike and <int64_t>arr[0] == iNaT:
if timelike and <int64_t>arr[0] == NPY_NAT:
return False, False, True

if algos_t is not object:
with nogil:
prev = arr[0]
for i in range(1, n):
cur = arr[i]
if timelike and <int64_t>cur == iNaT:
if timelike and <int64_t>cur 8000 == NPY_NAT:
is_monotonic_inc = 0
is_monotonic_dec = 0
break
Expand All @@ -851,7 +851,7 @@ def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike):
prev = arr[0]
for i in range(1, n):
cur = arr[i]
if timelike and <int64_t>cur == iNaT:
if timelike and <int64_t>cur == NPY_NAT:
is_monotonic_inc = 0
is_monotonic_dec = 0
break
Expand Down
6 changes: 3 additions & 3 deletions pandas/_libs/algos_rank_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def rank_1d_{{dtype}}(object in_arr, ties_method='average',
{{elif dtype == 'float64'}}
mask = np.isnan(values)
{{elif dtype == 'int64'}}
mask = values == iNaT
mask = values == NPY_NAT

# create copy in case of iNaT
# create copy in case of NPY_NAT
# values are mutated inplace
if mask.any():
values = values.copy()
Expand Down Expand Up @@ -257,7 +257,7 @@ def rank_2d_{{dtype}}(object in_arr, axis=0, ties_method='average',
{{elif dtype == 'float64'}}
mask = np.isnan(values)
{{elif dtype == 'int64'}}
mask = values == iNaT
mask = values == NPY_NAT
{{endif}}

np.putmask(values, mask, nan_value)
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from algos cimport (swap, TiebreakEnumType, TIEBREAK_AVERAGE, TIEBREAK_MIN,
TIEBREAK_MAX, TIEBREAK_FIRST, TIEBREAK_DENSE)
from algos import take_2d_axis1_float64_float64, groupsort_indexer, tiebreakers

cdef int64_t iNaT = get_nat()
cdef int64_t NPY_NAT = get_nat()

cdef float64_t NaN = <float64_t>np.NaN

Expand Down
14 changes: 7 additions & 7 deletions pandas/_libs/groupby_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def group_ohlc_{{name}}(ndarray[{{c_type}}, ndim=2] out,
# name, c_type, nan_val
dtypes = [('float64', 'float64_t', 'NAN'),
('float32', 'float32_t', 'NAN'),
('int64', 'int64_t', 'iNaT'),
('int64', 'int64_t', 'NPY_NAT'),
('object', 'object', 'NAN')]

def get_dispatch(dtypes):
Expand Down Expand Up @@ -630,7 +630,7 @@ def group_max(ndarray[groupby_t, ndim=2] out,
if groupby_t is int64_t:
# Note: evaluated at compile-time
maxx[:] = -_int64_max
nan_val = iNaT
nan_val = NPY_NAT
else:
maxx[:] = -np.inf
nan_val = NAN
Expand Down Expand Up @@ -692,7 +692,7 @@ def group_min(ndarray[groupby_t, ndim=2] out,
minx = np.empty_like(out)
if groupby_t is int64_t:
minx[:] = _int64_max
nan_val = iNaT
nan_val = NPY_NAT
else:
minx[:] = np.inf
nan_val = NAN
Expand Down Expand Up @@ -762,8 +762,8 @@ def group_cummin(ndarray[groupby_t, ndim=2] out,

# val = nan
if groupby_t is int64_t:
if is_datetimelike and val == iNaT:
out[i, j] = iNaT
if is_datetimelike and val == NPY_NAT:
out[i, j] = NPY_NAT
else:
mval = accum[lab, j]
if val < mval:
Expand Down Expand Up @@ -809,8 +809,8 @@ def group_cummax(ndarray[groupby_t, ndim=2] out,
val = values[i, j]

if groupby_t is int64_t:
if is_datetimelike and val == iNaT:
out[i, j] = iNaT
if is_datetimelike and val == NPY_NAT:
out[i, j] = NPY_NAT
else:
mval = accum[lab, j]
if val > mval:
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/hashtable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cimport util
from missing cimport checknull


cdef int64_t iNaT = util.get_nat()
cdef int64_t NPY_NAT = util.get_nat()
_SIZE_HINT_LIMIT = (1 << 20) + 7


Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/hashtable_class_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ cdef class HashTable:
# name, dtype, float_group, default_na_value
dtypes = [('Float64', 'float64', True, 'np.nan'),
('UInt64', 'uint64', False, 0),
('Int64', 'int64', False, 'iNaT')]
('Int64', 'int64', False, 'NPY_NAT')]

}}

Expand Down
0