_scalars.py 668 B

1234567891011121314151617181920212223242526
  1. from typing import Union, Tuple, Any
  2. import numpy as np
  3. # NOTE: `_StrLike` and `_BytesLike` are pointless, as `np.str_` and `np.bytes_`
  4. # are already subclasses of their builtin counterpart
  5. _CharLike = Union[str, bytes]
  6. _BoolLike = Union[bool, np.bool_]
  7. _IntLike = Union[int, np.integer]
  8. _FloatLike = Union[_IntLike, float, np.floating]
  9. _ComplexLike = Union[_FloatLike, complex, np.complexfloating]
  10. _NumberLike = Union[int, float, complex, np.number, np.bool_]
  11. _ScalarLike = Union[
  12. int,
  13. float,
  14. complex,
  15. str,
  16. bytes,
  17. np.generic,
  18. ]
  19. # `_VoidLike` is technically not a scalar, but it's close enough
  20. _VoidLike = Union[Tuple[Any, ...], np.void]