ops.pyi 1.3 KB

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