1from typing import Any, TypeAlias
2
3import numpy as np
4
5# NOTE: `_StrLike_co` and `_BytesLike_co` are pointless, as `np.str_` and
6# `np.bytes_` are already subclasses of their builtin counterpart
7
8_CharLike_co: TypeAlias = str | bytes
9
10# The 6 `<X>Like_co` type-aliases below represent all scalars that can be
11# coerced into `<X>` (with the casting rule `same_kind`)
12_BoolLike_co: TypeAlias = bool | np.bool
13_UIntLike_co: TypeAlias = np.unsignedinteger[Any] | _BoolLike_co
14_IntLike_co: TypeAlias = int | np.integer[Any] | _BoolLike_co
15_FloatLike_co: TypeAlias = float | np.floating[Any] | _IntLike_co
16_ComplexLike_co: TypeAlias = (
17 complex
18 | np.complexfloating[Any, Any]
19 | _FloatLike_co
20)
21_TD64Like_co: TypeAlias = np.timedelta64 | _IntLike_co
22
23_NumberLike_co: TypeAlias = int | float | complex | np.number[Any] | np.bool
24_ScalarLike_co: TypeAlias = int | float | complex | str | bytes | np.generic
25
26# `_VoidLike_co` is technically not a scalar, but it's close enough
27_VoidLike_co: TypeAlias = tuple[Any, ...] | np.void