Return len(a) element-wise. Parameters ---------- a : array_like of str or unicode Returns ------- out : ndarray Output array of integers See Also -------- len Examples -------- >>> a = np.array(['Grace Hopper Conference', 'Open Source
(a)
| 264 | |
| 265 | @array_function_dispatch(_unary_op_dispatcher) |
| 266 | def str_len(a): |
| 267 | """ |
| 268 | Return len(a) element-wise. |
| 269 | |
| 270 | Parameters |
| 271 | ---------- |
| 272 | a : array_like of str or unicode |
| 273 | |
| 274 | Returns |
| 275 | ------- |
| 276 | out : ndarray |
| 277 | Output array of integers |
| 278 | |
| 279 | See Also |
| 280 | -------- |
| 281 | len |
| 282 | |
| 283 | Examples |
| 284 | -------- |
| 285 | >>> a = np.array(['Grace Hopper Conference', 'Open Source Day']) |
| 286 | >>> np.char.str_len(a) |
| 287 | array([23, 15]) |
| 288 | >>> a = np.array([u'\u0420', u'\u043e']) |
| 289 | >>> np.char.str_len(a) |
| 290 | array([1, 1]) |
| 291 | >>> a = np.array([['hello', 'world'], [u'\u0420', u'\u043e']]) |
| 292 | >>> np.char.str_len(a) |
| 293 | array([[5, 5], [1, 1]]) |
| 294 | """ |
| 295 | # Note: __len__, etc. currently return ints, which are not C-integers. |
| 296 | # Generally intp would be expected for lengths, although int is sufficient |
| 297 | # due to the dtype itemsize limitation. |
| 298 | return _vec_string(a, int_, '__len__') |
| 299 | |
| 300 | |
| 301 | @array_function_dispatch(_binary_op_dispatcher) |
nothing calls this directly
no test coverage detected