ops.pyi 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from typing import (
  2. Any,
  3. Callable,
  4. Literal,
  5. overload,
  6. )
  7. import numpy as np
  8. _BinOp = Callable[[Any, Any], Any]
  9. _BoolOp = Callable[[Any, Any], bool]
  10. def scalar_compare(
  11. values: np.ndarray, # object[:]
  12. val: object,
  13. op: _BoolOp, # {operator.eq, operator.ne, ...}
  14. ) -> np.ndarray: ... # np.ndarray[bool]
  15. def vec_compare(
  16. left: np.ndarray, # np.ndarray[object]
  17. right: np.ndarray, # np.ndarray[object]
  18. op: _BoolOp, # {operator.eq, operator.ne, ...}
  19. ) -> np.ndarray: ... # np.ndarray[bool]
  20. def scalar_binop(
  21. values: np.ndarray, # object[:]
  22. val: object,
  23. op: _BinOp, # binary operator
  24. ) -> np.ndarray: ...
  25. def vec_binop(
  26. left: np.ndarray, # object[:]
  27. right: np.ndarray, # object[:]
  28. op: _BinOp, # binary operator
  29. ) -> np.ndarray: ...
  30. @overload
  31. def maybe_convert_bool(
  32. arr: np.ndarray, # np.ndarray[object]
  33. true_values=...,
  34. false_values=...,
  35. convert_to_masked_nullable: Literal[False] = ...,
  36. ) -> tuple[np.ndarray, None]: ...
  37. @overload
  38. def maybe_convert_bool(
  39. arr: np.ndarray, # np.ndarray[object]
  40. true_values=...,
  41. false_values=...,
  42. *,
  43. convert_to_masked_nullable: Literal[True],
  44. ) -> tuple[np.ndarray, np.ndarray]: ...