From d41edd5e2dbca4a3bc90cd314a1beafcfab82343 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 01:19:02 +0300 Subject: [PATCH 01/24] CLN: fix build warning --- pandas/_libs/groupby.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/groupby.pyx b/pandas/_libs/groupby.pyx index 8f662b57615f3..e3f18572abca1 100644 --- a/pandas/_libs/groupby.pyx +++ b/pandas/_libs/groupby.pyx @@ -260,7 +260,7 @@ def group_shift_indexer(int64_t[:] out, const int64_t[:] labels, int ngroups, int periods): cdef: Py_ssize_t N, i, j, ii - int offset, sign + int offset = 0, sign int64_t lab, idxer, idxer_slot int64_t[:] label_seen = np.zeros(ngroups, dtype=np.int64) int64_t[:, :] label_indexer From 160b55dbedda268cdafa7d20fa65b33616e81f8a Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 01:35:09 +0300 Subject: [PATCH 02/24] CLN: fix build warning --- pandas/_libs/groupby_helper.pxi.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/_libs/groupby_helper.pxi.in b/pandas/_libs/groupby_helper.pxi.in index 8e351244b7f43..7b9b75edfbd43 100644 --- a/pandas/_libs/groupby_helper.pxi.in +++ b/pandas/_libs/groupby_helper.pxi.in @@ -76,7 +76,11 @@ def group_last_{{name}}({{c_type}}[:, :] out, val = values[i, j] # not nan + {{if name.startswith("int")}} + if 0: + {{else}} if val == val and val != {{nan_val}}: + {{endif}} nobs[lab, j] += 1 resx[lab, j] = val @@ -133,7 +137,11 @@ def group_nth_{{name}}({{c_type}}[:, :] out, val = values[i, j] # not nan + {{if name.startswith("int")}} + if 0: + {{else}} if val == val and val != {{nan_val}}: + {{endif}} nobs[lab, j] += 1 if nobs[lab, j] == rank: resx[lab, j] = val From a6a252aeb721edf6c4683b3d6307403836fc634e Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 01:44:41 +0300 Subject: [PATCH 03/24] CLN: fix build warning --- pandas/_libs/hashtable.pxd | 2 +- pandas/_libs/hashtable.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/hashtable.pxd b/pandas/_libs/hashtable.pxd index 609420f429798..8ffee643278b4 100644 --- a/pandas/_libs/hashtable.pxd +++ b/pandas/_libs/hashtable.pxd @@ -41,7 +41,7 @@ cdef class StringHashTable(HashTable): cdef struct Int64VectorData: int64_t *data - size_t n, m + ssize_t n, m cdef class Int64Vector: cdef Int64VectorData *data diff --git a/pandas/_libs/hashtable.pyx b/pandas/_libs/hashtable.pyx index 544fb3d8a15c0..18f2dede7cba6 100644 --- a/pandas/_libs/hashtable.pyx +++ b/pandas/_libs/hashtable.pyx @@ -44,7 +44,7 @@ cdef int64_t NPY_NAT = util.get_nat() _SIZE_HINT_LIMIT = (1 << 20) + 7 -cdef size_t _INIT_VEC_CAP = 128 +cdef ssize_t _INIT_VEC_CAP = 128 include "hashtable_class_helper.pxi" include "hashtable_func_helper.pxi" From 125c97a4306f54ed43eb23ebd9389d16f6670d18 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 02:06:37 +0300 Subject: [PATCH 04/24] CLN: fix build warning --- pandas/_libs/hashtable_class_helper.pxi.in | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/hashtable_class_helper.pxi.in b/pandas/_libs/hashtable_class_helper.pxi.in index 8c2c560c062ac..be4a953f027b5 100644 --- a/pandas/_libs/hashtable_class_helper.pxi.in +++ b/pandas/_libs/hashtable_class_helper.pxi.in @@ -424,8 +424,13 @@ cdef class {{name}}HashTable(HashTable): for i in range(n): val = values[i] - if ignore_na and (val != val - or (use_na_value and val == na_value2)): + if ignore_na and ( + {{if name.lower().startswith(("uint", "int"))}} + 0 + {{else}} + val != val or (use_na_value and val == na_value2) + {{endif}} + ): # if missing values do not count as unique values (i.e. if # ignore_na is True), skip the hashtable entry for them, # and replace the corresponding label with na_sentinel @@ -1020,8 +1025,13 @@ cdef class PyObjectHashTable(HashTable): val = values[i] hash(val) - if ignore_na and ((val != val or val is None) - or (use_na_value and val == na_value)): + if ignore_na and ( + {{if name.lower().startswith(("uint", "int"))}} + 0 + {{else}} + (val != val or val is None) + or (use_na_value and val == na_value) + {{endif}}): # if missing values do not count as unique values (i.e. if # ignore_na is True), skip the hashtable entry for them, and # replace the corresponding label with na_sentinel From 0931a1a3ead214a5a6849aa4e62bd76e94c6c339 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 02:07:25 +0300 Subject: [PATCH 05/24] CLN: fix build warning --- pandas/_libs/hashtable_class_helper.pxi.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/hashtable_class_helper.pxi.in b/pandas/_libs/hashtable_class_helper.pxi.in index be4a953f027b5..042ecfc12f293 100644 --- a/pandas/_libs/hashtable_class_helper.pxi.in +++ b/pandas/_libs/hashtable_class_helper.pxi.in @@ -664,7 +664,7 @@ cdef class StringHashTable(HashTable): int64_t[:] locs = np.empty(n, dtype=np.int64) # these by-definition *must* be strings - vecs = malloc(n * sizeof(char *)) + vecs = malloc(n * sizeof(char *)) for i in range(n): val = values[i] From 50f819b5d8e01d80055a21179860a04c42b3863d Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 02:16:41 +0300 Subject: [PATCH 06/24] CLN: fix build warning --- pandas/_libs/hashtable_func_helper.pxi.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/hashtable_func_helper.pxi.in b/pandas/_libs/hashtable_func_helper.pxi.in index 80d864c65d087..e400ec0e608f0 100644 --- a/pandas/_libs/hashtable_func_helper.pxi.in +++ b/pandas/_libs/hashtable_func_helper.pxi.in @@ -241,7 +241,7 @@ def ismember_{{dtype}}({{scalar}}[:] arr, {{scalar}}[:] values): # construct the table n = len(values) - kh_resize_{{ttype}}(table, min(n, len(values))) + kh_resize_{{ttype}}(table, n) {{if dtype == 'object'}} for i in range(n): From ca7d77cbe97f2879eca290be91fbc2d07da3c036 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 02:20:16 +0300 Subject: [PATCH 07/24] CLN: fix build warning --- pandas/_libs/index.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index b7c3e0e4cdd63..046cab6c432f8 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -352,7 +352,7 @@ cdef class IndexEngine: cdef Py_ssize_t _bin_search(ndarray values, object val) except -1: cdef: - Py_ssize_t mid, lo = 0, hi = len(values) - 1 + Py_ssize_t mid = 0, lo = 0, hi = len(values) - 1 object pval if hi >= 0 and val > util.get_value_at(values, hi): From 75537d960a32f94bf98efd41da773dcb2e9a6d2a Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 03:09:47 +0300 Subject: [PATCH 08/24] CLN: fix build warning --- pandas/_libs/lib.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index c09fb96eb9182..aa3706b228464 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -477,7 +477,7 @@ def maybe_indices_to_slice(ndarray[int64_t] indices, int max_len): def maybe_booleans_to_slice(ndarray[uint8_t] mask): cdef: Py_ssize_t i, n = len(mask) - Py_ssize_t start, end + Py_ssize_t start = 0 , end = 0 bint started = 0, finished = 0 for i in range(n): From 168462dd7cd78a7a5e9937b3600521ebf3b6b5ed Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 03:09:52 +0300 Subject: [PATCH 09/24] CLN: fix build warning --- pandas/_libs/lib.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index aa3706b228464..19816aeb9ba2b 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -1631,7 +1631,7 @@ def is_datetime_with_singletz_array(values: ndarray) -> bool: Doesn't check values are datetime-like types. """ cdef: - Py_ssize_t i, j, n = len(values) + Py_ssize_t i = 0, j, n = len(values) object base_val, base_tz, val, tz if n == 0: From 913956d210f7997111fcaed9f134aa3b7597fff7 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 03:39:11 +0300 Subject: [PATCH 10/24] CLN: fix build warning --- pandas/_libs/lib.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 19816aeb9ba2b..87796d6219110 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -1913,8 +1913,8 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0, ndarray[int64_t] ints ndarray[uint64_t] uints ndarray[uint8_t] bools - ndarray[int64_t] idatetimes - ndarray[int64_t] itimedeltas + int64_t[::1] idatetimes + int64_t[::1] itimedeltas Seen seen = Seen() object val float64_t fval, fnan From 6554425366c433767ced174544309b4a414b85c9 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 03:47:55 +0300 Subject: [PATCH 11/24] CLN: fix build warning --- pandas/_libs/src/parser/tokenizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/src/parser/tokenizer.c b/pandas/_libs/src/parser/tokenizer.c index 3146e49455609..694f5f9019059 100644 --- a/pandas/_libs/src/parser/tokenizer.c +++ b/pandas/_libs/src/parser/tokenizer.c @@ -1815,7 +1815,7 @@ double round_trip(const char *p, char **q, char decimal, char sci, char tsep, double r = PyOS_string_to_double(p, q, 0); if (maybe_int != NULL) *maybe_int = 0; if (PyErr_Occurred() != NULL) *error = -1; - else if (r == Py_HUGE_VAL) *error = Py_HUGE_VAL; + else if (r == Py_HUGE_VAL) *error = (int)Py_HUGE_VAL; PyErr_Clear(); return r; } From 7e9117bf5c3725ecc483e4b1c095672deeac4c4d Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 03:47:59 +0300 Subject: [PATCH 12/24] CLN: fix build warning --- pandas/_libs/src/parser/tokenizer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/src/parser/tokenizer.c b/pandas/_libs/src/parser/tokenizer.c index 694f5f9019059..95bd68da638c4 100644 --- a/pandas/_libs/src/parser/tokenizer.c +++ b/pandas/_libs/src/parser/tokenizer.c @@ -424,13 +424,13 @@ static void append_warning(parser_t *self, const char *msg) { if (self->warn_msg == NULL) { self->warn_msg = (char *)malloc(length + 1); - strncpy(self->warn_msg, msg, strlen(msg) + 1); + strcpy(self->warn_msg, msg); } else { ex_length = strlen(self->warn_msg); newptr = safe_realloc(self->warn_msg, ex_length + length + 1); if (newptr != NULL) { self->warn_msg = (char *)newptr; - strncpy(self->warn_msg + ex_length, msg, strlen(msg) + 1); + strcpy(self->warn_msg + ex_length, msg); } } } @@ -1439,7 +1439,7 @@ int to_boolean(const char *item, uint8_t *val) { static const char *fstrs[1] = {"FALSE"}; tmp = malloc(bufsize); - strncpy(tmp, item, bufsize); + strcpy(tmp, item); uppercase(tmp); for (i = 0; i < 1; ++i) { From d2440ef20b81bc48c03e275b0594cdbb9cffb9bd Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 05:01:24 +0300 Subject: [PATCH 13/24] Revert "CLN: fix build warning" This reverts commit 125c97a4306f54ed43eb23ebd9389d16f6670d18. --- pandas/_libs/hashtable_class_helper.pxi.in | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/pandas/_libs/hashtable_class_helper.pxi.in b/pandas/_libs/hashtable_class_helper.pxi.in index 042ecfc12f293..bf2189a8c1fd7 100644 --- a/pandas/_libs/hashtable_class_helper.pxi.in +++ b/pandas/_libs/hashtable_class_helper.pxi.in @@ -424,13 +424,8 @@ cdef class {{name}}HashTable(HashTable): for i in range(n): val = values[i] - if ignore_na and ( - {{if name.lower().startswith(("uint", "int"))}} - 0 - {{else}} - val != val or (use_na_value and val == na_value2) - {{endif}} - ): + if ignore_na and (val != val + or (use_na_value and val == na_value2)): # if missing values do not count as unique values (i.e. if # ignore_na is True), skip the hashtable entry for them, # and replace the corresponding label with na_sentinel @@ -1025,13 +1020,8 @@ cdef class PyObjectHashTable(HashTable): val = values[i] hash(val) - if ignore_na and ( - {{if name.lower().startswith(("uint", "int"))}} - 0 - {{else}} - (val != val or val is None) - or (use_na_value and val == na_value) - {{endif}}): + if ignore_na and ((val != val or val is None) + or (use_na_value and val == na_value)): # if missing values do not count as unique values (i.e. if # ignore_na is True), skip the hashtable entry for them, and # replace the corresponding label with na_sentinel From 08b960678e279342601e75e813c992b43ef0fc1a Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 05:21:09 +0300 Subject: [PATCH 14/24] CLN: fix build warning --- pandas/_libs/hashtable_class_helper.pxi.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/hashtable_class_helper.pxi.in b/pandas/_libs/hashtable_class_helper.pxi.in index bf2189a8c1fd7..17f1d011af01b 100644 --- a/pandas/_libs/hashtable_class_helper.pxi.in +++ b/pandas/_libs/hashtable_class_helper.pxi.in @@ -424,8 +424,12 @@ cdef class {{name}}HashTable(HashTable): for i in range(n): val = values[i] - if ignore_na and (val != val - or (use_na_value and val == na_value2)): + if ignore_na and ( + {{if not name.lower().startswith(("uint", "int"))}} + val != val or + {{endif}} + (use_na_value and val == na_value2) + ): # if missing values do not count as unique values (i.e. if # ignore_na is True), skip the hashtable entry for them, # and replace the corresponding label with na_sentinel From 9db4c05fe6c66145446264af69db308eb97db904 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 07:04:43 +0300 Subject: [PATCH 15/24] CLN: fix test --- pandas/_libs/groupby_helper.pxi.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/_libs/groupby_helper.pxi.in b/pandas/_libs/groupby_helper.pxi.in index 7b9b75edfbd43..000689f634545 100644 --- a/pandas/_libs/groupby_helper.pxi.in +++ b/pandas/_libs/groupby_helper.pxi.in @@ -76,11 +76,11 @@ def group_last_{{name}}({{c_type}}[:, :] out, val = values[i, j] # not nan - {{if name.startswith("int")}} - if 0: - {{else}} - if val == val and val != {{nan_val}}: + if ( + {{if not name.startswith("int")}} + val == val and {{endif}} + val != {{nan_val}}): nobs[lab, j] += 1 resx[lab, j] = val @@ -137,11 +137,11 @@ def group_nth_{{name}}({{c_type}}[:, :] out, val = values[i, j] # not nan - {{if name.startswith("int")}} - if 0: - {{else}} - if val == val and val != {{nan_val}}: + if ( + {{if not name.startswith("int")}} + val == val and {{endif}} + val != {{nan_val}}): nobs[lab, j] += 1 if nobs[lab, j] == rank: resx[lab, j] = val From d91420676e9d9e979e72e728968c6412727dbb59 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 07:46:07 +0300 Subject: [PATCH 16/24] CEC8 --- pandas/_libs/lib.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 87796d6219110..58cbfdd2954d3 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -477,7 +477,7 @@ def maybe_indices_to_slice(ndarray[int64_t] indices, int max_len): def maybe_booleans_to_slice(ndarray[uint8_t] mask): cdef: Py_ssize_t i, n = len(mask) - Py_ssize_t start = 0 , end = 0 + Py_ssize_t start = 0, end = 0 bint started = 0, finished = 0 for i in range(n): From 71c7d62d5485c29e96621830403af1c3b656adea Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 16:40:04 +0300 Subject: [PATCH 17/24] CLN: use snprintf not strncpy to silence both compiler and cpplint --- pandas/_libs/src/parser/tokenizer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/src/parser/tokenizer.c b/pandas/_libs/src/parser/tokenizer.c index 95bd68da638c4..86f77125393fd 100644 --- a/pandas/_libs/src/parser/tokenizer.c +++ b/pandas/_libs/src/parser/tokenizer.c @@ -424,13 +424,13 @@ static void append_warning(parser_t *self, const char *msg) { if (self->warn_msg == NULL) { self->warn_msg = (char *)malloc(length + 1); - strcpy(self->warn_msg, msg); + snprintf(self->warn_msg, length + 1, "%s", msg); } else { ex_length = strlen(self->warn_msg); newptr = safe_realloc(self->warn_msg, ex_length + length + 1); if (newptr != NULL) { self->warn_msg = (char *)newptr; - strcpy(self->warn_msg + ex_length, msg); + snprintf(self->warn_msg + ex_length, length + 1, "%s", msg); } } } @@ -1433,13 +1433,14 @@ PANDAS_INLINE void uppercase(char *p) { int to_boolean(const char *item, uint8_t *val) { char *tmp; int i, status = 0; - int bufsize = sizeof(char) * (strlen(item) + 1); + size_t length0 = (strlen(item) + 1); + int bufsize = sizeof(char) * length0; static const char *tstrs[1] = {"TRUE"}; static const char *fstrs[1] = {"FALSE"}; tmp = malloc(bufsize); - strcpy(tmp, item); + snprintf(tmp, length0, "%s", item); uppercase(tmp); for (i = 0; i < 1; ++i) { From d2e8f664176cc2e7adaf5177edfb86a6f0855bba Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 19:02:00 +0300 Subject: [PATCH 18/24] Use Py_ssize_t not ssize_t --- pandas/_libs/hashtable.pxd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/hashtable.pxd b/pandas/_libs/hashtable.pxd index 8ffee643278b4..51ec4ba43159c 100644 --- a/pandas/_libs/hashtable.pxd +++ b/pandas/_libs/hashtable.pxd @@ -41,7 +41,7 @@ cdef class StringHashTable(HashTable): cdef struct Int64VectorData: int64_t *data - ssize_t n, m + Py_ssize_t n, m cdef class Int64Vector: cdef Int64VectorData *data From ac4c0b3de877c6465ba021bc7348f282069641b4 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 19:11:38 +0300 Subject: [PATCH 19/24] omit template changes --- pandas/_libs/groupby_helper.pxi.in | 12 ++---------- pandas/_libs/hashtable_class_helper.pxi.in | 8 ++------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/pandas/_libs/groupby_helper.pxi.in b/pandas/_libs/groupby_helper.pxi.in index 000689f634545..8e351244b7f43 100644 --- a/pandas/_libs/groupby_helper.pxi.in +++ b/pandas/_libs/groupby_helper.pxi.in @@ -76,11 +76,7 @@ def group_last_{{name}}({{c_type}}[:, :] out, val = values[i, j] # not nan - if ( - {{if not name.startswith("int")}} - val == val and - {{endif}} - val != {{nan_val}}): + if val == val and val != {{nan_val}}: nobs[lab, j] += 1 resx[lab, j] = val @@ -137,11 +133,7 @@ def group_nth_{{name}}({{c_type}}[:, :] out, val = values[i, j] # not nan - if ( - {{if not name.startswith("int")}} - val == val and - {{endif}} - val != {{nan_val}}): + if val == val and val != {{nan_val}}: nobs[lab, j] += 1 if nobs[lab, j] == rank: resx[lab, j] = val diff --git a/pandas/_libs/hashtable_class_helper.pxi.in b/pandas/_libs/hashtable_class_helper.pxi.in index 17f1d011af01b..bf2189a8c1fd7 100644 --- a/pandas/_libs/hashtable_class_helper.pxi.in +++ b/pandas/_libs/hashtable_class_helper.pxi.in @@ -424,12 +424,8 @@ cdef class {{name}}HashTable(HashTable): for i in range(n): val = values[i] - if ignore_na and ( - {{if not name.lower().startswith(("uint", "int"))}} - val != val or - {{endif}} - (use_na_value and val == na_value2) - ): + if ignore_na and (val != val + or (use_na_value and val == na_value2)): # if missing values do not count as unique values (i.e. if # ignore_na is True), skip the hashtable entry for them, # and replace the corresponding label with na_sentinel From 832d55d5d5128306eaa7b4c5977900070c2c2f6b Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 20:01:05 +0300 Subject: [PATCH 20/24] Retry CI From 790a8e7b8650c8dbd4b0dcf5d1b5b4956c4a3842 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 21:56:18 +0300 Subject: [PATCH 21/24] use Py_ssize_t --- pandas/_libs/hashtable.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/hashtable.pyx b/pandas/_libs/hashtable.pyx index 18f2dede7cba6..3e620f5934d5e 100644 --- a/pandas/_libs/hashtable.pyx +++ b/pandas/_libs/hashtable.pyx @@ -44,7 +44,7 @@ cdef int64_t NPY_NAT = util.get_nat() _SIZE_HINT_LIMIT = (1 << 20) + 7 -cdef ssize_t _INIT_VEC_CAP = 128 +cdef Py_ssize_t _INIT_VEC_CAP = 128 include "hashtable_class_helper.pxi" include "hashtable_func_helper.pxi" From 71b4df0e0353c7a101d54d28b43a0a47b909f363 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Mon, 1 Jul 2019 21:56:48 +0300 Subject: [PATCH 22/24] remove redundant sizeof --- pandas/_libs/src/parser/tokenizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/src/parser/tokenizer.c b/pandas/_libs/src/parser/tokenizer.c index 86f77125393fd..2752fb6424022 100644 --- a/pandas/_libs/src/parser/tokenizer.c +++ b/pandas/_libs/src/parser/tokenizer.c @@ -1434,7 +1434,7 @@ int to_boolean(const char *item, uint8_t *val) { char *tmp; int i, status = 0; size_t length0 = (strlen(item) + 1); - int bufsize = sizeof(char) * length0; + int bufsize = length0; static const char *tstrs[1] = {"TRUE"}; static const char *fstrs[1] = {"FALSE"}; From e464800384d72ed41e1982717b4cd739c8638c21 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Tue, 2 Jul 2019 00:35:53 +0300 Subject: [PATCH 23/24] Use memory views without specific memory layout --- pandas/_libs/lib.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 58cbfdd2954d3..9ef0a2a8094bb 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -1913,8 +1913,8 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0, ndarray[int64_t] ints ndarray[uint64_t] uints ndarray[uint8_t] bools - int64_t[::1] idatetimes - int64_t[::1] itimedeltas + int64_t[:] idatetimes + int64_t[:] itimedeltas Seen seen = Seen() object val float64_t fval, fnan From d8f3fa5b997ea78ff33e93a7f711cc5759cd0ce3 Mon Sep 17 00:00:00 2001 From: pilkibun Date: Tue, 2 Jul 2019 01:05:09 +0300 Subject: [PATCH 24/24] BUG: check for empty values in index.pyx/_bin_search --- pandas/_libs/index.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index 046cab6c432f8..ba2838d59f814 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -355,7 +355,7 @@ cdef Py_ssize_t _bin_search(ndarray values, object val) except -1: Py_ssize_t mid = 0, lo = 0, hi = len(values) - 1 object pval - if hi >= 0 and val > util.get_value_at(values, hi): + if hi == 0 or (hi > 0 and val > util.get_value_at(values, hi)): return len(values) while lo < hi: