Skip to content

Commit 40a3c97

Browse files
jbrockmendelvictor
authored and
victor
committed
Remove unused, avoid uses of deprecated api (pandas-dev#22071)
1 parent 10586fd commit 40a3c97

File tree

7 files changed

+237
-114
lines changed

7 files changed

+237
-114
lines changed

pandas/_libs/algos.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def is_lexsorted(list list_of_arrays):
129129
for i in range(nlevels):
130130
arr = list_of_arrays[i]
131131
assert arr.dtype.name == 'int64'
132-
vecs[i] = <int64_t*> arr.data
132+
vecs[i] = <int64_t*> cnp.PyArray_DATA(arr)
133133

134134
# Assume uniqueness??
135135
with nogil:

pandas/_libs/groupby.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ from cython cimport Py_ssize_t
77
from libc.stdlib cimport malloc, free
88

99
import numpy as np
10+
cimport numpy as cnp
1011
from numpy cimport (ndarray,
1112
double_t,
1213
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
1314
uint32_t, uint64_t, float32_t, float64_t)
15+
cnp.import_array()
1416

1517

1618
from util cimport numeric, get_nat
@@ -118,7 +120,7 @@ def group_median_float64(ndarray[float64_t, ndim=2] out,
118120
counts[:] = _counts[1:]
119121

120122
data = np.empty((K, N), dtype=np.float64)
121-
ptr = <float64_t*> data.data
123+
ptr = <float64_t*> cnp.PyArray_DATA(data)
122124

123125
take_2d_axis1_float64_float64(values.T, indexer, out=data)
124126

pandas/_libs/index.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cdef inline bint is_definitely_invalid_key(object val):
3737
return True
3838

3939
# we have a _data, means we are a NDFrame
40-
return (PySlice_Check(val) or cnp.PyArray_Check(val)
40+
return (PySlice_Check(val) or util.is_array(val)
4141
or PyList_Check(val) or hasattr(val, '_data'))
4242

4343

@@ -104,7 +104,7 @@ cdef class IndexEngine:
104104
void* data_ptr
105105

106106
loc = self.get_loc(key)
107-
if PySlice_Check(loc) or cnp.PyArray_Check(loc):
107+
if PySlice_Check(loc) or util.is_array(loc):
108108
return arr[loc]
109109
else:
110110
return get_value_at(arr, loc, tz=tz)
@@ -120,7 +120,7 @@ cdef class IndexEngine:
120120
loc = self.get_loc(key)
121121
value = convert_scalar(arr, value)
122122

123-
if PySlice_Check(loc) or cnp.PyArray_Check(loc):
123+
if PySlice_Check(loc) or util.is_array(loc):
124124
arr[loc] = value
125125
else:
126126
util.set_value_at(arr, loc, value)

pandas/_libs/src/numpy_helper.h

+3-11
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ The full license is in the LICENSE file, distributed with this software.
1616
#include "numpy/arrayscalars.h"
1717

1818

19-
PANDAS_INLINE npy_int64 get_nat(void) { return NPY_MIN_INT64; }
20-
2119
PANDAS_INLINE int assign_value_1d(PyArrayObject* ap, Py_ssize_t _i,
2220
PyObject* v) {
2321
npy_intp i = (npy_intp)_i;
@@ -40,16 +38,10 @@ PANDAS_INLINE const char* get_c_string(PyObject* obj) {
4038
#endif
4139
}
4240

43-
PANDAS_INLINE PyObject* char_to_string(const char* data) {
44-
#if PY_VERSION_HEX >= 0x03000000
45-
return PyUnicode_FromString(data);
46-
#else
47-
return PyString_FromString(data);
48-
#endif
49-
}
50-
5141
void set_array_not_contiguous(PyArrayObject* ao) {
52-
ao->flags &= ~(NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS);
42+
// Numpy>=1.8-compliant equivalent to:
43+
// ao->flags &= ~(NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS);
44+
PyArray_CLEARFLAGS(ao, (NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS));
5345
}
5446

5547
#endif // PANDAS__LIBS_SRC_NUMPY_HELPER_H_

pandas/_libs/tslibs/conversion.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
888888

889889
trans, deltas, typ = get_dst_info(tz)
890890

891-
tdata = <int64_t*> trans.data
891+
tdata = <int64_t*> cnp.PyArray_DATA(trans)
892892
ntrans = len(trans)
893893

894894
result_a = np.empty(n, dtype=np.int64)

0 commit comments

Comments
 (0)