Skip to content

Commit 72aed3e

Browse files
authored
Replaced numpy type aliases; fix CI failure (#34835)
1 parent 107ad15 commit 72aed3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+247
-277
lines changed

asv_bench/benchmarks/pandas_vb_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
np.uint8,
3434
]
3535
datetime_dtypes = [np.datetime64, np.timedelta64]
36-
string_dtypes = [np.object]
36+
string_dtypes = [object]
3737
try:
3838
extension_dtypes = [
3939
pd.Int8Dtype,

asv_bench/benchmarks/series_methods.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,15 @@ def time_isin_nan_values(self):
5858

5959
class IsInForObjects:
6060
def setup(self):
61-
self.s_nans = Series(np.full(10 ** 4, np.nan)).astype(np.object)
62-
self.vals_nans = np.full(10 ** 4, np.nan).astype(np.object)
63-
self.s_short = Series(np.arange(2)).astype(np.object)
64-
self.s_long = Series(np.arange(10 ** 5)).astype(np.object)
65-
self.vals_short = np.arange(2).astype(np.object)
66-
self.vals_long = np.arange(10 ** 5).astype(np.object)
61+
self.s_nans = Series(np.full(10 ** 4, np.nan)).astype(object)
62+
self.vals_nans = np.full(10 ** 4, np.nan).astype(object)
63+
self.s_short = Series(np.arange(2)).astype(object)
64+
self.s_long = Series(np.arange(10 ** 5)).astype(object)
65+
self.vals_short = np.arange(2).astype(object)
66+
self.vals_long = np.arange(10 ** 5).astype(object)
6767
# because of nans floats are special:
68-
self.s_long_floats = Series(np.arange(10 ** 5, dtype=np.float)).astype(
69-
np.object
70-
)
71-
self.vals_long_floats = np.arange(10 ** 5, dtype=np.float).astype(np.object)
68+
self.s_long_floats = Series(np.arange(10 ** 5, dtype=np.float)).astype(object)
69+
self.vals_long_floats = np.arange(10 ** 5, dtype=np.float).astype(object)
7270

7371
def time_isin_nans(self):
7472
# if nan-objects are different objects,

asv_bench/benchmarks/sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def time_series_to_frame(self):
3232

3333
class SparseArrayConstructor:
3434

35-
params = ([0.1, 0.01], [0, np.nan], [np.int64, np.float64, np.object])
35+
params = ([0.1, 0.01], [0, np.nan], [np.int64, np.float64, object])
3636
param_names = ["dense_proportion", "fill_value", "dtype"]
3737

3838
def setup(self, dense_proportion, fill_value, dtype):

doc/source/user_guide/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ Fallback behavior
18841884
If the JSON serializer cannot handle the container contents directly it will
18851885
fall back in the following manner:
18861886

1887-
* if the dtype is unsupported (e.g. ``np.complex``) then the ``default_handler``, if provided, will be called
1887+
* if the dtype is unsupported (e.g. ``np.complex_``) then the ``default_handler``, if provided, will be called
18881888
for each value, otherwise an exception is raised.
18891889

18901890
* if an object is unsupported it will attempt the following:

pandas/_libs/hashtable_class_helper.pxi.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ cdef class StringVector:
178178
Py_ssize_t n
179179
object val
180180

181-
ao = np.empty(self.data.n, dtype=np.object)
181+
ao = np.empty(self.data.n, dtype=object)
182182
for i in range(self.data.n):
183183
val = self.data.data[i]
184184
ao[i] = val

pandas/_libs/hashtable_func_helper.pxi.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ cpdef value_count_{{dtype}}({{c_type}}[:] values, bint dropna):
9494
build_count_table_{{dtype}}(values, table, dropna)
9595
{{endif}}
9696

97-
result_keys = np.empty(table.n_occupied, dtype=np.{{dtype}})
97+
result_keys = np.empty(table.n_occupied, '{{dtype}}')
9898
result_counts = np.zeros(table.n_occupied, dtype=np.int64)
9999

100100
{{if dtype == 'object'}}

pandas/_libs/parsers.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ def _concatenate_chunks(list chunks):
20372037
numpy_dtypes = {x for x in dtypes if not is_categorical_dtype(x)}
20382038
if len(numpy_dtypes) > 1:
20392039
common_type = np.find_common_type(numpy_dtypes, [])
2040-
if common_type == np.object:
2040+
if common_type == object:
20412041
warning_columns.append(str(name))
20422042

20432043
dtype = dtypes.pop()

pandas/_libs/sparse.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,4 +791,4 @@ def make_mask_object_ndarray(ndarray[object, ndim=1] arr, object fill_value):
791791
if value == fill_value and type(value) == type(fill_value):
792792
mask[i] = 0
793793

794-
return mask.view(dtype=np.bool)
794+
return mask.view(dtype=bool)

pandas/_libs/testing.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cdef NUMERIC_TYPES = (
1111
bool,
1212
int,
1313
float,
14-
np.bool,
14+
np.bool_,
1515
np.int8,
1616
np.int16,
1717
np.int32,

pandas/core/algorithms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _ensure_data(
171171
return values, dtype
172172

173173
# we have failed, return object
174-
values = np.asarray(values, dtype=np.object)
174+
values = np.asarray(values, dtype=object)
175175
return ensure_object(values), np.dtype("object")
176176

177177

0 commit comments

Comments
 (0)