Skip to content

Commit c9b7bed

Browse files
committed
undo change to lower bound
1 parent 9dc03e1 commit c9b7bed

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

pandas/lib.pyx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,8 @@ cdef int64_t NPY_NAT = util.get_nat()
6565
ctypedef unsigned char UChar
6666

6767
cimport util
68-
from util cimport is_array, _checknull, _checknan
69-
70-
cdef extern from "headers/stdint.h":
71-
enum: UINT8_MAX
72-
enum: INT64_MAX
73-
enum: INT64_MIN
74-
68+
from util cimport (is_array, _checknull, _checknan, INT64_MAX,
69+
INT64_MIN, UINT8_MAX)
7570

7671
cdef extern from "math.h":
7772
double sqrt(double x)

pandas/src/inference.pyx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,9 @@ iNaT = util.get_nat()
66

77
cdef bint PY2 = sys.version_info[0] == 2
88

9-
cdef extern from "headers/stdint.h":
10-
enum: UINT8_MAX
11-
enum: UINT16_MAX
12-
enum: UINT32_MAX
13-
enum: UINT64_MAX
14-
enum: INT8_MIN
15-
enum: INT8_MAX
16-
enum: INT16_MIN
17-
enum: INT16_MAX
18-
enum: INT32_MAX
19-
enum: INT32_MIN
20-
enum: INT64_MAX
21-
enum: INT64_MIN
9+
from util cimport (UINT8_MAX, UINT16_MAX, UINT32_MAX, UINT64_MAX,
10+
INT8_MIN, INT8_MAX, INT16_MIN, INT16_MAX,
11+
INT32_MAX, INT32_MIN, INT64_MAX, INT64_MIN)
2212

2313
# core.common import for fast inference checks
2414

pandas/src/util.pxd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ ctypedef fused numeric:
3838
cnp.float32_t
3939
cnp.float64_t
4040

41+
cdef extern from "headers/stdint.h":
42+
enum: UINT8_MAX
43+
enum: UINT16_MAX
44+
enum: UINT32_MAX
45+
enum: UINT64_MAX
46+
enum: INT8_MIN
47+
enum: INT8_MAX
48+
enum: INT16_MIN
49+
enum: INT16_MAX
50+
enum: INT32_MAX
51+
enum: INT32_MIN
52+
enum: INT64_MAX
53+
enum: INT64_MIN
54+
4155
cdef inline object get_value_at(ndarray arr, object loc):
4256
cdef:
4357
Py_ssize_t i, sz

pandas/tslib.pyx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ from cpython cimport (
2525
)
2626

2727

28-
cdef extern from "headers/stdint.h":
29-
enum: INT64_MAX
30-
enum: INT64_MIN
31-
3228
# Cython < 0.17 doesn't have this in cpython
3329
cdef extern from "Python.h":
3430
cdef PyTypeObject *Py_TYPE(object)
@@ -42,7 +38,7 @@ from datetime cimport cmp_pandas_datetimestruct
4238
from libc.stdlib cimport free
4339

4440
from util cimport (is_integer_object, is_float_object, is_datetime64_object,
45-
is_timedelta64_object)
41+
is_timedelta64_object, INT64_MAX)
4642
cimport util
4743

4844
from datetime cimport *
@@ -909,9 +905,12 @@ cpdef object get_value_box(ndarray arr, object loc):
909905

910906

911907
# Add the min and max fields at the class level
912-
# INT64_MIN is reserved for NaT
913-
cdef int64_t _NS_LOWER_BOUND = INT64_MIN + 1
914908
cdef int64_t _NS_UPPER_BOUND = INT64_MAX
909+
# smallest value we could actually represent is
910+
# INT64_MIN + 1 == -9223372036854775807
911+
# but to allow overflow free conversion with a microsecond resolution
912+
# use the smallest value with a 0 nanosecond unit
913+
cdef int64_t _NS_LOWER_BOUND = -9223285636854775000LL
915914

916915
cdef pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS
917916
pandas_datetime_to_datetimestruct(_NS_LOWER_BOUND, PANDAS_FR_ns, &_NS_MIN_DTS)

0 commit comments

Comments
 (0)