@@ -79,7 +79,7 @@ def test_string_accessors_type_preserving_index() -> None:
79
79
_check (assert_type (idx .str .zfill (10 ), "pd.Index[str]" ))
80
80
81
81
82
- def test_string_accessors_type_boolean_series ():
82
+ def test_string_accessors_boolean_series ():
83
83
s = pd .Series (DATA )
84
84
_check = functools .partial (check , klass = pd .Series , dtype = bool )
85
85
_check (assert_type (s .str .startswith ("a" ), "pd.Series[bool]" ))
@@ -107,7 +107,7 @@ def test_string_accessors_type_boolean_series():
107
107
_check (assert_type (s .str .match ("pp" ), "pd.Series[bool]" ))
108
108
109
109
110
- def test_string_accessors_type_boolean_index ():
110
+ def test_string_accessors_boolean_index ():
111
111
idx = pd .Index (DATA )
112
112
_check = functools .partial (check , klass = np .ndarray , dtype = np .bool_ )
113
113
_check (assert_type (idx .str .startswith ("a" ), np_ndarray_bool ))
@@ -135,7 +135,7 @@ def test_string_accessors_type_boolean_index():
135
135
_check (assert_type (idx .str .match ("pp" ), np_ndarray_bool ))
136
136
137
137
138
- def test_string_accessors_type_integer_series ():
138
+ def test_string_accessors_integer_series ():
139
139
s = pd .Series (DATA )
140
140
_check = functools .partial (check , klass = pd .Series , dtype = np .integer )
141
141
_check (assert_type (s .str .find ("p" ), "pd.Series[int]" ))
@@ -146,7 +146,7 @@ def test_string_accessors_type_integer_series():
146
146
_check (assert_type (s .str .len (), "pd.Series[int]" ))
147
147
148
148
149
- def test_string_accessors_type_integer_index ():
149
+ def test_string_accessors_integer_index ():
150
150
idx = pd .Index (DATA )
151
151
_check = functools .partial (check , klass = pd .Index , dtype = np .integer )
152
152
_check (assert_type (idx .str .find ("p" ), "pd.Index[int]" ))
@@ -157,19 +157,30 @@ def test_string_accessors_type_integer_index():
157
157
_check (assert_type (idx .str .len (), "pd.Index[int]" ))
158
158
159
159
160
- def test_string_accessors_encode_decode ():
161
- s_str = pd .Series (["a1" , "b2" , "c3" ])
162
- s_bytes = pd .Series ([b"a1" , b"b2" , b"c3" ])
160
+ def test_string_accessors_string_series ():
161
+ s = pd .Series ([b"a1" , b"b2" , b"c3" ])
162
+ _check = functools .partial (check , klass = pd .Series , dtype = str )
163
+ _check (assert_type (s .str .decode ("utf-8" ), "pd.Series[str]" ))
163
164
s2 = pd .Series ([["apple" , "banana" ], ["cherry" , "date" ], [1 , "eggplant" ]])
164
- check (
165
- assert_type (s_bytes .str .decode ("utf-8" ), "pd.Series[str]" ),
166
- pd .Series ,
167
- str ,
168
- )
169
- check (
170
- assert_type (s_str .str .encode ("latin-1" ), "pd.Series[bytes]" ), pd .Series , bytes
171
- )
172
- check (assert_type (s2 .str .join ("-" ), "pd.Series[str]" ), pd .Series , str )
165
+ _check (assert_type (s2 .str .join ("-" ), "pd.Series[str]" ))
166
+
167
+
168
+ def test_string_accessors_string_index ():
169
+ idx = pd .Index ([b"a1" , b"b2" , b"c3" ])
170
+ _check = functools .partial (check , klass = pd .Index , dtype = str )
171
+ _check (assert_type (idx .str .decode ("utf-8" ), "pd.Index[str]" ))
172
+ idx2 = pd .Index ([["apple" , "banana" ], ["cherry" , "date" ], [1 , "eggplant" ]])
173
+ _check (assert_type (idx2 .str .join ("-" ), "pd.Index[str]" ))
174
+
175
+
176
+ def test_string_accessors_bytes_series ():
177
+ s = pd .Series (["a1" , "b2" , "c3" ])
178
+ check (assert_type (s .str .encode ("latin-1" ), "pd.Series[bytes]" ), pd .Series , bytes )
179
+
180
+
181
+ def test_string_accessors_bytes_index ():
182
+ s = pd .Index (["a1" , "b2" , "c3" ])
183
+ check (assert_type (s .str .encode ("latin-1" ), "pd.Index[bytes]" ), pd .Index , bytes )
173
184
174
185
175
186
def test_string_accessors_list ():
0 commit comments