Skip to content

Commit

Permalink
more intp whackamole
Browse files Browse the repository at this point in the history
  • Loading branch information
Terji Petersen authored and Terji Petersen committed Nov 8, 2022
1 parent 8b52054 commit 527be72
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pandas/core/indexes/base.py
Expand Up @@ -1051,7 +1051,7 @@ def astype(self, dtype, copy: bool = True):
UInt64Index,
)

klass: Index
klass: type[Index]
if is_signed_integer_dtype(dtype):
klass = Int64Index
elif is_unsigned_integer_dtype(dtype):
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/arrays/categorical/test_repr.py
Expand Up @@ -111,7 +111,7 @@ def test_categorical_repr(self):

assert repr(c) == exp

c = Categorical(np.arange(20))
c = Categorical(np.arange(20, dtype=np.int64))
exp = """[0, 1, 2, 3, 4, ..., 15, 16, 17, 18, 19]
Length: 20
Categories (20, int64): [0, 1, 2, 3, ..., 16, 17, 18, 19]"""
Expand All @@ -138,7 +138,7 @@ def test_categorical_repr_ordered(self):

assert repr(c) == exp

c = Categorical(np.arange(20), ordered=True)
c = Categorical(np.arange(20, dtype=np.int64), ordered=True)
exp = """[0, 1, 2, 3, 4, ..., 15, 16, 17, 18, 19]
Length: 20
Categories (20, int64): [0 < 1 < 2 < 3 ... 16 < 17 < 18 < 19]"""
Expand Down Expand Up @@ -380,7 +380,7 @@ def test_categorical_index_repr(self):
exp = """CategoricalIndex([1, 2, 3], categories=[1, 2, 3], ordered=False, dtype='category')""" # noqa:E501
assert repr(idx) == exp

i = CategoricalIndex(Categorical(np.arange(10)))
i = CategoricalIndex(Categorical(np.arange(10, dtype=np.int64)))
exp = """CategoricalIndex([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], categories=[0, 1, 2, 3, ..., 6, 7, 8, 9], ordered=False, dtype='category')""" # noqa:E501
assert repr(i) == exp

Expand All @@ -389,7 +389,7 @@ def test_categorical_index_repr_ordered(self):
exp = """CategoricalIndex([1, 2, 3], categories=[1, 2, 3], ordered=True, dtype='category')""" # noqa:E501
assert repr(i) == exp

i = CategoricalIndex(Categorical(np.arange(10), ordered=True))
i = CategoricalIndex(Categorical(np.arange(10, dtype=np.int64), ordered=True))
exp = """CategoricalIndex([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], categories=[0, 1, 2, 3, ..., 6, 7, 8, 9], ordered=True, dtype='category')""" # noqa:E501
assert repr(i) == exp

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/interval/test_interval.py
Expand Up @@ -167,7 +167,7 @@ def test_repr():
expected = (
"<IntervalArray>\n"
"[(0, 1], (1, 2]]\n"
"Length: 2, dtype: interval[int64, right]"
f"Length: 2, dtype: interval[{np.intp.__name__}, right]"
)
assert result == expected

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/test_array.py
Expand Up @@ -155,7 +155,7 @@
(
[pd.Interval(1, 2), pd.Interval(3, 4)],
"interval",
IntervalArray.from_tuples([(1, 2), (3, 4)]),
IntervalArray.from_tuples([(1, 2), (3, 4)], dtype=np.int64),
),
# Sparse
([0, 1], "Sparse[int64]", SparseArray([0, 1], dtype="int64")),
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/extension/decimal/test_decimal.py
Expand Up @@ -443,7 +443,8 @@ def DecimalArray__my_sum(self):
result = df.groupby("id")["decimals"].agg(lambda x: x.values.my_sum())
tm.assert_series_equal(result, expected, check_names=False)
s = pd.Series(DecimalArray(data))
result = s.groupby(np.array([0, 0, 0, 1, 1])).agg(lambda x: x.values.my_sum())
grouper = np.array([0, 0, 0, 1, 1], dtype=np.int64)
result = s.groupby(grouper).agg(lambda x: x.values.my_sum())
tm.assert_series_equal(result, expected, check_names=False)


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/constructors/test_from_dict.py
Expand Up @@ -85,7 +85,7 @@ def test_constructor_list_of_series(self):
expected = DataFrame.from_dict(sdict, orient="index")
tm.assert_frame_equal(result, expected.reindex(result.index))

result2 = DataFrame(data, index=np.arange(6))
result2 = DataFrame(data, index=np.arange(6, dtype=np.int64))
tm.assert_frame_equal(result, result2)

result = DataFrame([Series(dtype=object)])
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/frame/indexing/test_where.py
Expand Up @@ -647,7 +647,8 @@ def test_df_where_change_dtype(self):
@pytest.mark.parametrize("kwargs", [{}, {"other": None}])
def test_df_where_with_category(self, kwargs):
# GH#16979
df = DataFrame(np.arange(2 * 3).reshape(2, 3), columns=list("ABC"))
data = np.arange(2 * 3, dtype=np.int64).reshape(2, 3)
df = DataFrame(data, columns=list("ABC"))
mask = np.array([[True, False, False], [False, False, True]])

# change type to category
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/methods/test_to_csv.py
Expand Up @@ -62,8 +62,8 @@ def test_to_csv_from_csv1(self, float_frame, datetime_frame):
# corner case
dm = DataFrame(
{
"s1": Series(range(3), index=np.arange(3)),
"s2": Series(range(2), index=np.arange(2)),
"s1": Series(range(3), index=np.arange(3, dtype=np.int64)),
"s2": Series(range(2), index=np.arange(2, dtype=np.int64)),
}
)
dm.to_csv(path)
Expand Down Expand Up @@ -486,7 +486,7 @@ def test_to_csv_multiindex(self, float_frame, datetime_frame):

frame = float_frame
old_index = frame.index
arrays = np.arange(len(old_index) * 2).reshape(2, -1)
arrays = np.arange(len(old_index) * 2, dtype=np.int64).reshape(2, -1)
new_index = MultiIndex.from_arrays(arrays, names=["first", "second"])
frame.index = new_index

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_reductions.py
Expand Up @@ -589,7 +589,7 @@ def test_mode_sortwarning(self):
def test_mode_empty_df(self):
df = DataFrame([], columns=["a", "b"])
result = df.mode()
expected = DataFrame([], columns=["a", "b"], index=Index([], dtype=int))
expected = DataFrame([], columns=["a", "b"], index=Index([], dtype=np.int64))
tm.assert_frame_equal(result, expected)

def test_operators_timedelta64(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_algos.py
Expand Up @@ -1773,7 +1773,7 @@ def test_pad(self):

# corner case
old = Index([5, 10])
new = Index(np.arange(5))
new = Index(np.arange(5, dtype=np.int64))
filler = libalgos.pad["int64_t"](old.values, new.values)
expect_filler = np.array([-1, -1, -1, -1, -1], dtype=np.intp)
tm.assert_numpy_array_equal(filler, expect_filler)
Expand Down

0 comments on commit 527be72

Please sign in to comment.