Skip to content

Commit 860c99c

Browse files
jbrockmendeljreback
authored andcommitted
Remove src/numpy.pxd (#19418)
1 parent 5f6c80b commit 860c99c

File tree

3 files changed

+25
-999
lines changed

3 files changed

+25
-999
lines changed

pandas/_libs/index.pyx

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ from cpython.slice cimport PySlice_Check
88

99
import numpy as np
1010
cimport numpy as cnp
11-
from numpy cimport (ndarray, float64_t, int32_t, int64_t, uint8_t, uint64_t,
12-
NPY_DATETIME, NPY_TIMEDELTA)
11+
from numpy cimport ndarray, float64_t, int32_t, int64_t, uint8_t, uint64_t
1312
cnp.import_array()
1413

14+
cdef extern from "numpy/arrayobject.h":
15+
# These can be cimported directly from numpy in cython>=0.27.3
16+
cdef enum NPY_TYPES:
17+
NPY_DATETIME
18+
NPY_TIMEDELTA
1519

1620
cimport util
1721

pandas/_libs/src/inference.pyx

+19-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ iNaT = util.get_nat()
1212
cdef bint PY2 = sys.version_info[0] == 2
1313
cdef double nan = <double> np.NaN
1414

15+
cdef extern from "numpy/arrayobject.h":
16+
# cython's numpy.dtype specification is incorrect, which leads to
17+
# errors in issubclass(self.dtype.type, np.bool_), so we directly
18+
# include the correct version
19+
# https://github.com/cython/cython/issues/2022
20+
21+
ctypedef class numpy.dtype [object PyArray_Descr]:
22+
# Use PyDataType_* macros when possible, however there are no macros
23+
# for accessing some of the fields, so some are defined. Please
24+
# ask on cython-dev if you need more.
25+
cdef int type_num
26+
cdef int itemsize "elsize"
27+
cdef char byteorder
28+
cdef object fields
29+
cdef tuple names
30+
1531
from util cimport UINT8_MAX, UINT64_MAX, INT64_MAX, INT64_MIN
1632

1733
# core.common import for fast inference checks
@@ -609,13 +625,13 @@ cdef class Validator:
609625

610626
cdef:
611627
Py_ssize_t n
612-
cnp.dtype dtype
628+
dtype dtype
613629
bint skipna
614630

615631
def __cinit__(
616632
self,
617633
Py_ssize_t n,
618-
cnp.dtype dtype=np.dtype(np.object_),
634+
dtype dtype=np.dtype(np.object_),
619635
bint skipna=False
620636
):
621637
self.n = n
@@ -823,7 +839,7 @@ cdef class TemporalValidator(Validator):
823839
def __cinit__(
824840
self,
825841
Py_ssize_t n,
826-
cnp.dtype dtype=np.dtype(np.object_),
842+
dtype dtype=np.dtype(np.object_),
827843
bint skipna=False
828844
):
829845
self.n = n

0 commit comments

Comments
 (0)