Skip to content

Commit b8c754e

Browse files
committed
https://github.com/pandas-dev/pandas-stubs/pull/1462/files/9409ca00bff10f24c48218f3268279ec5d33cc70#r2511081138
1 parent 9409ca0 commit b8c754e

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

tests/test_pandas.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
check,
3535
np_1darray,
3636
np_1darray_anyint,
37+
np_1darray_bool,
3738
np_1darray_dt,
3839
np_1darray_float,
3940
np_1darray_int64,
@@ -446,18 +447,18 @@ def test_isna() -> None:
446447
check(assert_type(pd.notna(df), "pd.DataFrame"), pd.DataFrame)
447448

448449
idx = pd.Index([1, 2, np.nan, float("nan")])
449-
check(assert_type(pd.isna(idx), np_1darray[np.bool]), np_1darray[np.bool])
450-
check(assert_type(pd.notna(idx), np_1darray[np.bool]), np_1darray[np.bool])
450+
check(assert_type(pd.isna(idx), np_1darray_bool), np_1darray_bool)
451+
check(assert_type(pd.notna(idx), np_1darray_bool), np_1darray_bool)
451452

452453
# ExtensionArray
453454
ext_arr = idx.array
454-
check(assert_type(pd.isna(ext_arr), np_1darray[np.bool]), np_1darray[np.bool])
455-
check(assert_type(pd.notna(ext_arr), np_1darray[np.bool]), np_1darray[np.bool])
455+
check(assert_type(pd.isna(ext_arr), np_1darray_bool), np_1darray_bool)
456+
check(assert_type(pd.notna(ext_arr), np_1darray_bool), np_1darray_bool)
456457

457458
# 1-D numpy array
458459
arr_1d = idx.to_numpy()
459-
check(assert_type(pd.isna(arr_1d), np_1darray[np.bool]), np_1darray[np.bool])
460-
check(assert_type(pd.notna(arr_1d), np_1darray[np.bool]), np_1darray[np.bool])
460+
check(assert_type(pd.isna(arr_1d), np_1darray_bool), np_1darray_bool)
461+
check(assert_type(pd.notna(arr_1d), np_1darray_bool), np_1darray_bool)
461462

462463
# 2-D numpy array
463464
arr_2d = idx.to_numpy().reshape(2, 2)
@@ -471,8 +472,8 @@ def test_isna() -> None:
471472

472473
# List of scalars
473474
l_sca = [1, 2.5, float("nan")]
474-
check(assert_type(pd.isna(l_sca), np_1darray[np.bool]), np_1darray[np.bool])
475-
check(assert_type(pd.notna(l_sca), np_1darray[np.bool]), np_1darray[np.bool])
475+
check(assert_type(pd.isna(l_sca), np_1darray_bool), np_1darray_bool)
476+
check(assert_type(pd.notna(l_sca), np_1darray_bool), np_1darray_bool)
476477

477478
# List of unknown members
478479
l_any: list[object] = [arr_1d, ext_arr]
@@ -900,33 +901,33 @@ def test_lreshape() -> None:
900901

901902
def test_factorize() -> None:
902903
codes, uniques = pd.factorize(np.array(["b", "b", "a", "c", "b"]))
903-
check(assert_type(codes, np_1darray[np.int64]), np_1darray[np.int64])
904+
check(assert_type(codes, np_1darray_int64), np_1darray_int64)
904905
check(assert_type(uniques, np_1darray), np_1darray)
905906

906907
codes, uniques = pd.factorize(np.recarray((1,), dtype=[("x", int)]))
907-
check(assert_type(codes, np_1darray[np.int64]), np_1darray[np.int64])
908+
check(assert_type(codes, np_1darray_int64), np_1darray_int64)
908909
check(assert_type(uniques, np_1darray), np_1darray)
909910

910911
codes, cat_uniques = pd.factorize(pd.Categorical(["b", "b", "a", "c", "b"]))
911-
check(assert_type(codes, np_1darray[np.int64]), np_1darray[np.int64])
912+
check(assert_type(codes, np_1darray_int64), np_1darray_int64)
912913
check(assert_type(cat_uniques, pd.Categorical), pd.Categorical)
913914

914915
codes, idx_uniques = pd.factorize(pd.Index(["b", "b", "a", "c", "b"]))
915-
check(assert_type(codes, np_1darray[np.int64]), np_1darray[np.int64])
916+
check(assert_type(codes, np_1darray_int64), np_1darray_int64)
916917
check(assert_type(idx_uniques, pd.Index), pd.Index)
917918

918919
codes, idx_uniques = pd.factorize(pd.Series(["b", "b", "a", "c", "b"]))
919-
check(assert_type(codes, np_1darray[np.int64]), np_1darray[np.int64])
920+
check(assert_type(codes, np_1darray_int64), np_1darray_int64)
920921
check(assert_type(idx_uniques, pd.Index), pd.Index)
921922

922923
codes, uniques = pd.factorize(np.array(list("bbacb")))
923-
check(assert_type(codes, np_1darray[np.int64]), np_1darray[np.int64])
924+
check(assert_type(codes, np_1darray_int64), np_1darray_int64)
924925
check(assert_type(uniques, np_1darray), np_1darray)
925926

926927
codes, uniques = pd.factorize(
927928
np.array(["b", "b", "a", "c", "b"]), use_na_sentinel=True, size_hint=10
928929
)
929-
check(assert_type(codes, np_1darray[np.int64]), np_1darray[np.int64])
930+
check(assert_type(codes, np_1darray_int64), np_1darray_int64)
930931
check(assert_type(uniques, np_1darray), np_1darray)
931932

932933

@@ -985,10 +986,7 @@ def test_cut() -> None:
985986
b = pd.cut([1, 2, 3, 4, 5, 6, 7, 8], 4, labels=False, duplicates="raise")
986987
c = pd.cut([1, 2, 3, 4, 5, 6, 7, 8], 4, labels=["1", "2", "3", "4"])
987988
check(assert_type(a, pd.Categorical), pd.Categorical)
988-
check(
989-
assert_type(b, np_1darray[np.intp]),
990-
np_1darray[np.intp],
991-
)
989+
check(assert_type(b, np_1darray_intp), np_1darray_intp)
992990
check(assert_type(c, pd.Categorical), pd.Categorical)
993991

994992
d0, d1 = pd.cut([1, 2, 3, 4, 5, 6, 7, 8], 4, retbins=True)
@@ -998,7 +996,7 @@ def test_cut() -> None:
998996
)
999997
check(assert_type(d0, pd.Categorical), pd.Categorical)
1000998
check(assert_type(d1, np_1darray_float), np_1darray, np.floating)
1001-
check(assert_type(e0, np_1darray[np.intp]), np_1darray[np.intp])
999+
check(assert_type(e0, np_1darray_intp), np_1darray_intp)
10021000
check(assert_type(e1, np_1darray_float), np_1darray, np.floating)
10031001
check(assert_type(f0, pd.Categorical), pd.Categorical)
10041002
check(assert_type(f1, np_1darray_float), np_1darray, np.floating)

0 commit comments

Comments
 (0)