Skip to content

Commit 138be88

Browse files
jbrockmendeljreback
authored andcommitted
Remove from numpy cimport * (#17521)
1 parent 643fc1e commit 138be88

File tree

8 files changed

+32
-73
lines changed

8 files changed

+32
-73
lines changed

pandas/_libs/algos.pyx

+11-23
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# cython: profile=False
22

3-
from numpy cimport *
43
cimport numpy as np
54
import numpy as np
65

76
cimport cython
7+
from cython cimport Py_ssize_t
88

9-
import_array()
9+
np.import_array()
1010

1111
cdef float64_t FP_ERR = 1e-13
1212

@@ -15,31 +15,19 @@ cimport util
1515
from libc.stdlib cimport malloc, free
1616
from libc.string cimport memmove
1717

18-
from numpy cimport NPY_INT8 as NPY_int8
19-
from numpy cimport NPY_INT16 as NPY_int16
20-
from numpy cimport NPY_INT32 as NPY_int32
21-
from numpy cimport NPY_INT64 as NPY_int64
22-
from numpy cimport NPY_FLOAT16 as NPY_float16
23-
from numpy cimport NPY_FLOAT32 as NPY_float32
24-
from numpy cimport NPY_FLOAT64 as NPY_float64
25-
26-
from numpy cimport (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
27-
uint32_t, uint64_t, float16_t, float32_t, float64_t)
28-
29-
int8 = np.dtype(np.int8)
30-
int16 = np.dtype(np.int16)
31-
int32 = np.dtype(np.int32)
32-
int64 = np.dtype(np.int64)
33-
float16 = np.dtype(np.float16)
34-
float32 = np.dtype(np.float32)
35-
float64 = np.dtype(np.float64)
18+
from numpy cimport (ndarray,
19+
NPY_INT64, NPY_UINT64, NPY_INT32, NPY_INT16, NPY_INT8,
20+
NPY_FLOAT32, NPY_FLOAT64,
21+
NPY_OBJECT,
22+
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
23+
uint32_t, uint64_t, float16_t, float32_t, float64_t,
24+
double_t)
25+
3626

3727
cdef double NaN = <double> np.NaN
3828
cdef double nan = NaN
3929

40-
cdef extern from "../src/headers/math.h":
41-
double sqrt(double x) nogil
42-
double fabs(double) nogil
30+
from libc.math cimport sqrt, fabs
4331

4432
# this is our util.pxd
4533
from util cimport numeric, get_nat

pandas/_libs/groupby.pyx

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# cython: profile=False
22

3-
from numpy cimport *
4-
cimport numpy as np
3+
cimport numpy as cnp
54
import numpy as np
65

76
cimport cython
87

9-
import_array()
8+
cnp.import_array()
109

1110
cimport util
1211

13-
from numpy cimport (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
12+
from numpy cimport (ndarray,
13+
double_t,
14+
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
1415
uint32_t, uint64_t, float16_t, float32_t, float64_t)
1516

1617
from libc.stdlib cimport malloc, free

pandas/_libs/hashtable.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from khash cimport (
2323
kh_put_pymap, kh_resize_pymap)
2424

2525

26-
from numpy cimport *
26+
from numpy cimport ndarray, uint8_t, uint32_t
2727

2828
from libc.stdlib cimport malloc, free
2929
from cpython cimport (PyMem_Malloc, PyMem_Realloc, PyMem_Free,
@@ -56,8 +56,6 @@ cdef extern from "datetime.h":
5656

5757
PyDateTime_IMPORT
5858

59-
cdef extern from "Python.h":
60-
int PySlice_Check(object)
6159

6260
cdef size_t _INIT_VEC_CAP = 128
6361

pandas/_libs/interval.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
cimport numpy as np
22
import numpy as np
3-
import pandas as pd
43

54
cimport util
65
cimport cython
76
import cython
8-
from numpy cimport *
7+
from numpy cimport ndarray
98
from tslib import Timestamp
109

1110
from cpython.object cimport (Py_EQ, Py_NE, Py_GT, Py_LT, Py_GE, Py_LE,

pandas/_libs/intervaltree.pxi.in

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ Template for intervaltree
44
WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
55
"""
66

7-
from numpy cimport int64_t, float64_t
8-
from numpy cimport ndarray, PyArray_ArgSort, NPY_QUICKSORT, PyArray_Take
7+
from numpy cimport (
8+
int64_t, int32_t, float64_t, float32_t,
9+
ndarray,
10+
PyArray_ArgSort, NPY_QUICKSORT, PyArray_Take)
911
import numpy as np
1012

1113
cimport cython
14+
from cython cimport Py_ssize_t
15+
1216
cimport numpy as cnp
1317
cnp.import_array()
1418

pandas/_libs/join.pyx

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
11
# cython: profile=False
22

3-
from numpy cimport *
43
cimport numpy as np
54
import numpy as np
65

76
cimport cython
7+
from cython cimport Py_ssize_t
88

9-
import_array()
9+
np.import_array()
1010

1111
cimport util
1212

13-
from numpy cimport NPY_INT8 as NPY_int8
14-
from numpy cimport NPY_INT16 as NPY_int16
15-
from numpy cimport NPY_INT32 as NPY_int32
16-
from numpy cimport NPY_INT64 as NPY_int64
17-
from numpy cimport NPY_FLOAT16 as NPY_float16
18-
from numpy cimport NPY_FLOAT32 as NPY_float32
19-
from numpy cimport NPY_FLOAT64 as NPY_float64
20-
21-
from numpy cimport (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
13+
from numpy cimport (ndarray,
14+
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
2215
uint32_t, uint64_t, float16_t, float32_t, float64_t)
2316

24-
int8 = np.dtype(np.int8)
25-
int16 = np.dtype(np.int16)
26-
int32 = np.dtype(np.int32)
27-
int64 = np.dtype(np.int64)
28-
float16 = np.dtype(np.float16)
29-
float32 = np.dtype(np.float32)
30-
float64 = np.dtype(np.float64)
31-
3217
cdef double NaN = <double> np.NaN
3318
cdef double nan = NaN
3419

pandas/_libs/reshape.pyx

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
11
# cython: profile=False
22

3-
from numpy cimport *
43
cimport numpy as np
54
import numpy as np
65

76
cimport cython
7+
from cython cimport Py_ssize_t
88

9-
import_array()
9+
np.import_array()
1010

1111
cimport util
1212

13-
from numpy cimport NPY_INT8 as NPY_int8
14-
from numpy cimport NPY_INT16 as NPY_int16
15-
from numpy cimport NPY_INT32 as NPY_int32
16-
from numpy cimport NPY_INT64 as NPY_int64
17-
from numpy cimport NPY_FLOAT16 as NPY_float16
18-
from numpy cimport NPY_FLOAT32 as NPY_float32
19-
from numpy cimport NPY_FLOAT64 as NPY_float64
20-
21-
from numpy cimport (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
13+
from numpy cimport (ndarray,
14+
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
2215
uint32_t, uint64_t, float16_t, float32_t, float64_t)
2316

24-
int8 = np.dtype(np.int8)
25-
int16 = np.dtype(np.int16)
26-
int32 = np.dtype(np.int32)
27-
int64 = np.dtype(np.int64)
28-
float16 = np.dtype(np.float16)
29-
float32 = np.dtype(np.float32)
30-
float64 = np.dtype(np.float64)
31-
3217
cdef double NaN = <double> np.NaN
3318
cdef double nan = NaN
3419

pandas/_libs/src/reduce.pyx

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#cython=False
2-
from numpy cimport *
32
import numpy as np
43

54
from distutils.version import LooseVersion

0 commit comments

Comments
 (0)