Skip to content

Commit b0cade6

Browse files
committed
integer return type
1 parent 2463ce9 commit b0cade6

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

tests/test_string_accessors.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
import re
33

44
import numpy as np
5+
import numpy.typing as npt
56
import pandas as pd
67
from typing_extensions import assert_type
78

89
from tests import check
910

11+
# Separately define here so pytest works
12+
np_ndarray_bool = npt.NDArray[np.bool_]
13+
14+
1015
DATA = ["applep", "bananap", "Cherryp", "DATEp", "eGGpLANTp", "123p", "23.45p"]
1116

1217

@@ -105,29 +110,29 @@ def test_string_accessors_type_boolean_series():
105110
def test_string_accessors_type_boolean_index():
106111
idx = pd.Index(DATA)
107112
_check = functools.partial(check, klass=np.ndarray, dtype=np.bool_)
108-
_check(assert_type(idx.str.startswith("a"), "npt.NDArray[np.bool_]"))
113+
_check(assert_type(idx.str.startswith("a"), np_ndarray_bool))
109114
_check(
110-
assert_type(idx.str.startswith(("a", "b")), "npt.NDArray[np.bool_]"),
115+
assert_type(idx.str.startswith(("a", "b")), np_ndarray_bool),
111116
)
112117
_check(
113-
assert_type(idx.str.contains("a"), "npt.NDArray[np.bool_]"),
118+
assert_type(idx.str.contains("a"), np_ndarray_bool),
114119
)
115120
_check(
116-
assert_type(idx.str.contains(re.compile(r"a")), "npt.NDArray[np.bool_]"),
121+
assert_type(idx.str.contains(re.compile(r"a")), np_ndarray_bool),
117122
)
118-
_check(assert_type(idx.str.endswith("e"), "npt.NDArray[np.bool_]"))
119-
_check(assert_type(idx.str.endswith(("e", "f")), "npt.NDArray[np.bool_]"))
120-
_check(assert_type(idx.str.fullmatch("apple"), "npt.NDArray[np.bool_]"))
121-
_check(assert_type(idx.str.isalnum(), "npt.NDArray[np.bool_]"))
122-
_check(assert_type(idx.str.isalpha(), "npt.NDArray[np.bool_]"))
123-
_check(assert_type(idx.str.isdecimal(), "npt.NDArray[np.bool_]"))
124-
_check(assert_type(idx.str.isdigit(), "npt.NDArray[np.bool_]"))
125-
_check(assert_type(idx.str.isnumeric(), "npt.NDArray[np.bool_]"))
126-
_check(assert_type(idx.str.islower(), "npt.NDArray[np.bool_]"))
127-
_check(assert_type(idx.str.isspace(), "npt.NDArray[np.bool_]"))
128-
_check(assert_type(idx.str.istitle(), "npt.NDArray[np.bool_]"))
129-
_check(assert_type(idx.str.isupper(), "npt.NDArray[np.bool_]"))
130-
_check(assert_type(idx.str.match("pp"), "npt.NDArray[np.bool_]"))
123+
_check(assert_type(idx.str.endswith("e"), np_ndarray_bool))
124+
_check(assert_type(idx.str.endswith(("e", "f")), np_ndarray_bool))
125+
_check(assert_type(idx.str.fullmatch("apple"), np_ndarray_bool))
126+
_check(assert_type(idx.str.isalnum(), np_ndarray_bool))
127+
_check(assert_type(idx.str.isalpha(), np_ndarray_bool))
128+
_check(assert_type(idx.str.isdecimal(), np_ndarray_bool))
129+
_check(assert_type(idx.str.isdigit(), np_ndarray_bool))
130+
_check(assert_type(idx.str.isnumeric(), np_ndarray_bool))
131+
_check(assert_type(idx.str.islower(), np_ndarray_bool))
132+
_check(assert_type(idx.str.isspace(), np_ndarray_bool))
133+
_check(assert_type(idx.str.istitle(), np_ndarray_bool))
134+
_check(assert_type(idx.str.isupper(), np_ndarray_bool))
135+
_check(assert_type(idx.str.match("pp"), np_ndarray_bool))
131136

132137

133138
def test_string_accessors_type_integer_series():

0 commit comments

Comments
 (0)