Skip to content

Commit

Permalink
32-bit stuff III
Browse files Browse the repository at this point in the history
  • Loading branch information
Terji Petersen authored and topper-123 committed Dec 1, 2022
1 parent bcd9d6b commit 8020af4
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_value_counts.py
Expand Up @@ -88,7 +88,7 @@ def test_data_frame_value_counts_empty():
df_no_cols = pd.DataFrame()

result = df_no_cols.value_counts()
expected = pd.Series([], dtype=np.int64, index=np.array([], dtype=np.int_))
expected = pd.Series([], dtype=np.int64, index=np.array([], dtype=np.intp))

tm.assert_series_equal(result, expected)

Expand All @@ -97,7 +97,7 @@ def test_data_frame_value_counts_empty_normalize():
df_no_cols = pd.DataFrame()

result = df_no_cols.value_counts(normalize=True)
expected = pd.Series([], dtype=np.float64, index=np.array([], dtype=np.int_))
expected = pd.Series([], dtype=np.float64, index=np.array([], dtype=np.intp))

tm.assert_series_equal(result, expected)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/aggregate/test_cython.py
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.intp)
grps = np.arange(0, 25, 5, dtype=np.int_)
# 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
Expand Up @@ -113,7 +113,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.intp)
expected.index = expected.index.astype(np.int_)
tm.assert_series_equal(result, expected, check_exact=True)


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_nunique.py
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.intp), columns=test.columns)
expected = DataFrame([2], index=np.array([0], dtype=np.int_), columns=test.columns)
tm.assert_frame_equal(result, expected)


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_size.py
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.intp)
expected.index = expected.index.astype(np.int_)

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/indexes/test_index_new.py
Expand Up @@ -283,7 +283,7 @@ def test_constructor_int_dtype_nan_raises(self, dtype):
)
def test_constructor_dtypes_to_int64(self, vals):
index = Index(vals, dtype=int)
assert isinstance(index, NumericIndex) and index.dtype == np.intp
assert isinstance(index, NumericIndex) and index.dtype == np.int_

@pytest.mark.parametrize(
"vals",
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/multiindex/test_partial.py
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.intp
assert mi.levels[0].dtype == np.int_
else:
assert mi.levels[0].dtype == np.float64

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

msg = (
rf"\"None of \[NumericIndex\(\[1, 2\], dtype='{np.intp().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[1, 2\], dtype='{np.int_().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.intp().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[-1, -2\], dtype='{np.int_().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.intp().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[-2\], dtype='{np.int_().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.intp().dtype}'\)\] are "
rf"\"None of \[NumericIndex\(\[3\], dtype='{np.int_().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.intp().dtype}')] "
f"\"None of [NumericIndex([3], dtype='{np.int_().dtype}')] "
'are in the [index]"'
)
with pytest.raises(KeyError, match=re.escape(msg)):
Expand Down Expand Up @@ -1212,7 +1212,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.intp().dtype}'\)\] "
rf"None of \[NumericIndex\(\[0, 1\], dtype='{np.int_().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
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.intp().dtype}'\)\] "
rf"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='{np.int_().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.intp().dtype}', "
rf"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='{np.int_().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
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 == "intp"
assert df["key_0"].dtype == "int_"

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.intp, name="key_0")
expected = Series([1, 1, 1, 1, 2, 2, 3, 4, 5], dtype=np.int_, name="key_0")
tm.assert_series_equal(merged["key_0"], expected)

left = DataFrame({"value": np.arange(3)})
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/reshape/test_pivot.py
Expand Up @@ -2052,9 +2052,7 @@ def __init__(self, *args, **kwargs) -> None:
msg = "The following operation may generate"
with tm.assert_produces_warning(PerformanceWarning, match=msg):
with pytest.raises(Exception, match="Don't compute final result."):
df.pivot_table(
index="ind1", columns="ind2", values="count", aggfunc="count"
)
df.pivot_table(index="ind1", columns="ind2", values="count", aggfunc="count")

def test_pivot_table_aggfunc_dropna(self, dropna):
# GH 22159
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_constructors.py
Expand Up @@ -1199,7 +1199,7 @@ def test_construction_interval(self, interval_constructor):
# construction from interval & array of intervals
intervals = interval_constructor.from_breaks(np.arange(3), closed="right")
result = Series(intervals)
assert result.dtype == f"interval[{np.intp().dtype}, right]"
assert result.dtype == f"interval[{np.int_().dtype}, right]"
tm.assert_index_equal(Index(result.values), Index(intervals))

@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/test_repr.py
Expand Up @@ -333,7 +333,7 @@ def test_categorical_series_repr(self):
8 8
9 9
dtype: category
Categories (10, {np.intp().dtype}): [0, 1, 2, 3, ..., 6, 7, 8, 9]"""
Categories (10, {np.int_().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.intp().dtype}): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9]"""
Categories (10, {np.int_().dtype}): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9]"""

assert repr(s) == exp

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/window/test_groupby.py
Expand Up @@ -920,8 +920,8 @@ def test_nan_and_zero_endpoints(self):
name="adl2",
index=MultiIndex.from_arrays(
[
Index([0] * 999 + [1], dtype=np.intp, name="index"),
Index([0] * 999 + [1], dtype=np.intp, name="index"),
Index([0] * 999 + [1], dtype=np.int_, name="index"),
Index([0] * 999 + [1], dtype=np.int_, name="index"),
],
),
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/window/test_pairwise.py
Expand Up @@ -99,7 +99,7 @@ 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.intp)
exp.columns = exp.columns.astype(np.int_)
tm.assert_frame_equal(res3, exp)


Expand Down

0 comments on commit 8020af4

Please sign in to comment.