Skip to content

Commit

Permalink
np.int_ -> np.intp
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 committed Jan 4, 2023
1 parent 2af89ac commit d759966
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pandas/tests/groupby/aggregate/test_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_cython_agg_empty_buckets_nanops(observed):
# GH-18869 can't call nanops on empty groups, so hardcode expected
# for these
df = DataFrame([11, 12, 13], columns=["a"])
grps = np.arange(0, 25, 5, dtype=np.int_)
grps = np.arange(0, 25, 5, dtype=np.intp)
# add / sum
result = df.groupby(pd.cut(df["a"], grps), observed=observed)._cython_agg_general(
"sum", alt=None, numeric_only=True
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_min_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_max_inat_not_all_na():

# Note: in converting to float64, the iNaT + 1 maps to iNaT, i.e. is lossy
expected = Series({1: np.nan, 2: np.nan, 3: iNaT + 1})
expected.index = expected.index.astype(np.int_)
expected.index = expected.index.astype(np.intp)
tm.assert_series_equal(result, expected, check_exact=True)


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_nunique.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_nunique_preserves_column_level_names():
# GH 23222
test = DataFrame([1, 2, 2], columns=pd.Index(["A"], name="level_0"))
result = test.groupby([0, 0, 0]).nunique()
expected = DataFrame([2], index=np.array([0], dtype=np.int_), columns=test.columns)
expected = DataFrame([2], index=np.array([0], dtype=np.intp), columns=test.columns)
tm.assert_frame_equal(result, expected)


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_size_axis_1(df, axis_1, by, sort, dropna):
if sort:
expected = expected.sort_index()
if tm.is_integer_dtype(expected.index) and not any(x is None for x in by):
expected.index = expected.index.astype(np.int_)
expected.index = expected.index.astype(np.intp)

grouped = df.groupby(by=by, axis=axis_1, sort=sort, dropna=dropna)
result = grouped.size()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/multiindex/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_getitem_intkey_leading_level(
mi = ser.index
assert isinstance(mi, MultiIndex)
if dtype is int:
assert mi.levels[0].dtype == np.int_
assert mi.levels[0].dtype == np.intpq
else:
assert mi.levels[0].dtype == np.float64

Expand Down
12 changes: 6 additions & 6 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def test_loc_to_fail(self):
)

msg = (
rf"\"None of \[NumericIndex\(\[1, 2\], dtype='{np.int_().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[1, 2\], dtype='{np.intp().dtype}'\)\] are "
r"in the \[index\]\""
)
with pytest.raises(KeyError, match=msg):
Expand All @@ -454,7 +454,7 @@ def test_loc_to_fail2(self):
s.loc[-1]

msg = (
rf"\"None of \[NumericIndex\(\[-1, -2\], dtype='{np.int_().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[-1, -2\], dtype='{np.intp().dtype}'\)\] are "
r"in the \[index\]\""
)
with pytest.raises(KeyError, match=msg):
Expand All @@ -470,7 +470,7 @@ def test_loc_to_fail2(self):

s["a"] = 2
msg = (
rf"\"None of \[NumericIndex\(\[-2\], dtype='{np.int_().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[-2\], dtype='{np.intp().dtype}'\)\] are "
r"in the \[index\]\""
)
with pytest.raises(KeyError, match=msg):
Expand All @@ -487,7 +487,7 @@ def test_loc_to_fail3(self):
df = DataFrame([["a"], ["b"]], index=[1, 2], columns=["value"])

msg = (
rf"\"None of \[NumericIndex\(\[3\], dtype='{np.int_().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[3\], dtype='{np.intp().dtype}'\)\] are "
r"in the \[index\]\""
)
with pytest.raises(KeyError, match=msg):
Expand All @@ -505,7 +505,7 @@ def test_loc_getitem_list_with_fail(self):
s.loc[[2]]

msg = (
f"\"None of [NumericIndex([3], dtype='{np.int_().dtype}')] "
f"\"None of [NumericIndex([3], dtype='{np.intp().dtype}')] "
'are in the [index]"'
)
with pytest.raises(KeyError, match=re.escape(msg)):
Expand Down Expand Up @@ -1195,7 +1195,7 @@ def test_loc_setitem_empty_append_raises(self):
df = DataFrame(columns=["x", "y"])
df.index = df.index.astype(np.int64)
msg = (
rf"None of \[NumericIndex\(\[0, 1\], dtype='{np.int_().dtype}'\)\] "
rf"None of \[NumericIndex\(\[0, 1\], dtype='{np.intp().dtype}'\)\] "
r"are in the \[index\]"
)
with pytest.raises(KeyError, match=msg):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexing/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def test_series_partial_set(self):

# raises as nothing is in the index
msg = (
rf"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='{np.int_().dtype}'\)\] "
rf"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='{np.intp().dtype}'\)\] "
r"are in the \[index\]\""
)
with pytest.raises(KeyError, match=msg):
Expand Down Expand Up @@ -484,7 +484,7 @@ def test_series_partial_set_with_name(self):

# raises as nothing is in the index
msg = (
rf"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='{np.int_().dtype}', "
rf"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='{np.intp().dtype}', "
r"name='idx'\)\] are in the \[index\]\""
)
with pytest.raises(KeyError, match=msg):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_merge_join_key_dtype_cast(self):
lkey = np.array([1])
rkey = np.array([2])
df = merge(df1, df2, left_on=lkey, right_on=rkey, how="outer")
assert df["key_0"].dtype == "int_"
assert df["key_0"].dtype == np.intp

def test_handle_join_key_pass_array(self):
left = DataFrame(
Expand All @@ -379,7 +379,7 @@ def test_handle_join_key_pass_array(self):
rkey = np.array([1, 1, 2, 3, 4, 5])

merged = merge(left, right, left_on=lkey, right_on=rkey, how="outer")
expected = Series([1, 1, 1, 1, 2, 2, 3, 4, 5], dtype=np.int_, name="key_0")
expected = Series([1, 1, 1, 1, 2, 2, 3, 4, 5], dtype=np.intp, name="key_0")
tm.assert_series_equal(merged["key_0"], expected)

left = DataFrame({"value": np.arange(3)})
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def test_categorical_series_repr(self):
8 8
9 9
dtype: category
Categories (10, {np.int_().dtype}): [0, 1, 2, 3, ..., 6, 7, 8, 9]"""
Categories (10, {np.intp().dtype}): [0, 1, 2, 3, ..., 6, 7, 8, 9]"""

assert repr(s) == exp

Expand All @@ -359,7 +359,7 @@ def test_categorical_series_repr_ordered(self):
8 8
9 9
dtype: category
Categories (10, {np.int_().dtype}): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9]"""
Categories (10, {np.intp().dtype}): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9]"""

assert repr(s) == exp

Expand Down
1 change: 0 additions & 1 deletion pandas/tests/window/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def frame():
return DataFrame(
np.random.randn(100, 10),
index=bdate_range(datetime(2009, 1, 1), periods=100),
columns=np.arange(10),
)


Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/window/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,7 @@ def test_nan_and_zero_endpoints(self):
arr,
name="adl2",
index=MultiIndex.from_arrays(
[
Index([0] * 999 + [1], dtype=np.int_, name="index"),
Index([0] * 999 + [1], dtype=np.int_, name="index"),
],
[[0] * 999 + [1], [0] * 999 + [1]], names=["index", "index"]
),
)
tm.assert_series_equal(result, expected)
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/window/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def test_flex_binary_frame(method, frame):
exp = DataFrame(
{k: getattr(frame[k].rolling(window=10), method)(frame2[k]) for k in frame}
)
exp.columns = exp.columns.astype(np.int_)
tm.assert_frame_equal(res3, exp)


Expand Down

0 comments on commit d759966

Please sign in to comment.