matrix.pyi 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from typing import Any, TypeAlias
  2. import numpy as np
  3. import numpy.typing as npt
  4. from typing_extensions import assert_type
  5. _Shape2D: TypeAlias = tuple[int, int]
  6. mat: np.matrix[_Shape2D, np.dtype[np.int64]]
  7. ar_f8: npt.NDArray[np.float64]
  8. assert_type(mat * 5, np.matrix[_Shape2D, Any])
  9. assert_type(5 * mat, np.matrix[_Shape2D, Any])
  10. mat *= 5
  11. assert_type(mat**5, np.matrix[_Shape2D, Any])
  12. mat **= 5
  13. assert_type(mat.sum(), Any)
  14. assert_type(mat.mean(), Any)
  15. assert_type(mat.std(), Any)
  16. assert_type(mat.var(), Any)
  17. assert_type(mat.prod(), Any)
  18. assert_type(mat.any(), np.bool)
  19. assert_type(mat.all(), np.bool)
  20. assert_type(mat.max(), np.int64)
  21. assert_type(mat.min(), np.int64)
  22. assert_type(mat.argmax(), np.intp)
  23. assert_type(mat.argmin(), np.intp)
  24. assert_type(mat.ptp(), np.int64)
  25. assert_type(mat.sum(axis=0), np.matrix[_Shape2D, Any])
  26. assert_type(mat.mean(axis=0), np.matrix[_Shape2D, Any])
  27. assert_type(mat.std(axis=0), np.matrix[_Shape2D, Any])
  28. assert_type(mat.var(axis=0), np.matrix[_Shape2D, Any])
  29. assert_type(mat.prod(axis=0), np.matrix[_Shape2D, Any])
  30. assert_type(mat.any(axis=0), np.matrix[_Shape2D, np.dtype[np.bool]])
  31. assert_type(mat.all(axis=0), np.matrix[_Shape2D, np.dtype[np.bool]])
  32. assert_type(mat.max(axis=0), np.matrix[_Shape2D, np.dtype[np.int64]])
  33. assert_type(mat.min(axis=0), np.matrix[_Shape2D, np.dtype[np.int64]])
  34. assert_type(mat.argmax(axis=0), np.matrix[_Shape2D, np.dtype[np.intp]])
  35. assert_type(mat.argmin(axis=0), np.matrix[_Shape2D, np.dtype[np.intp]])
  36. assert_type(mat.ptp(axis=0), np.matrix[_Shape2D, np.dtype[np.int64]])
  37. assert_type(mat.sum(out=ar_f8), npt.NDArray[np.float64])
  38. assert_type(mat.mean(out=ar_f8), npt.NDArray[np.float64])
  39. assert_type(mat.std(out=ar_f8), npt.NDArray[np.float64])
  40. assert_type(mat.var(out=ar_f8), npt.NDArray[np.float64])
  41. assert_type(mat.prod(out=ar_f8), npt.NDArray[np.float64])
  42. assert_type(mat.any(out=ar_f8), npt.NDArray[np.float64])
  43. assert_type(mat.all(out=ar_f8), npt.NDArray[np.float64])
  44. assert_type(mat.max(out=ar_f8), npt.NDArray[np.float64])
  45. assert_type(mat.min(out=ar_f8), npt.NDArray[np.float64])
  46. assert_type(mat.argmax(out=ar_f8), npt.NDArray[np.float64])
  47. assert_type(mat.argmin(out=ar_f8), npt.NDArray[np.float64])
  48. assert_type(mat.ptp(out=ar_f8), npt.NDArray[np.float64])
  49. assert_type(mat.T, np.matrix[_Shape2D, np.dtype[np.int64]])
  50. assert_type(mat.I, np.matrix[_Shape2D, Any])
  51. assert_type(mat.A, np.ndarray[_Shape2D, np.dtype[np.int64]])
  52. assert_type(mat.A1, npt.NDArray[np.int64])
  53. assert_type(mat.H, np.matrix[_Shape2D, np.dtype[np.int64]])
  54. assert_type(mat.getT(), np.matrix[_Shape2D, np.dtype[np.int64]])
  55. assert_type(mat.getI(), np.matrix[_Shape2D, Any])
  56. assert_type(mat.getA(), np.ndarray[_Shape2D, np.dtype[np.int64]])
  57. assert_type(mat.getA1(), npt.NDArray[np.int64])
  58. assert_type(mat.getH(), np.matrix[_Shape2D, np.dtype[np.int64]])
  59. assert_type(np.bmat(ar_f8), np.matrix[_Shape2D, Any])
  60. assert_type(np.bmat([[0, 1, 2]]), np.matrix[_Shape2D, Any])
  61. assert_type(np.bmat("mat"), np.matrix[_Shape2D, Any])
  62. assert_type(np.asmatrix(ar_f8, dtype=np.int64), np.matrix[_Shape2D, Any])