fromnumeric.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. """Tests for :mod:`numpy.core.fromnumeric`."""
  2. import numpy as np
  3. A = np.array(True, ndmin=2, dtype=bool)
  4. A.setflags(write=False)
  5. a = np.bool_(True)
  6. np.take(a, None) # E: incompatible type
  7. np.take(a, axis=1.0) # E: incompatible type
  8. np.take(A, out=1) # E: incompatible type
  9. np.take(A, mode="bob") # E: incompatible type
  10. np.reshape(a, None) # E: Argument 2 to "reshape" has incompatible type
  11. np.reshape(A, 1, order="bob") # E: Argument "order" to "reshape" has incompatible type
  12. np.choose(a, None) # E: incompatible type
  13. np.choose(a, out=1.0) # E: incompatible type
  14. np.choose(A, mode="bob") # E: incompatible type
  15. np.repeat(a, None) # E: Argument 2 to "repeat" has incompatible type
  16. np.repeat(A, 1, axis=1.0) # E: Argument "axis" to "repeat" has incompatible type
  17. np.swapaxes(A, None, 1) # E: Argument 2 to "swapaxes" has incompatible type
  18. np.swapaxes(A, 1, [0]) # E: Argument 3 to "swapaxes" has incompatible type
  19. np.transpose(A, axes=1.0) # E: Argument "axes" to "transpose" has incompatible type
  20. np.partition(a, None) # E: Argument 2 to "partition" has incompatible type
  21. np.partition(
  22. a, 0, axis="bob" # E: Argument "axis" to "partition" has incompatible type
  23. )
  24. np.partition(
  25. A, 0, kind="bob" # E: Argument "kind" to "partition" has incompatible type
  26. )
  27. np.partition(
  28. A, 0, order=range(5) # E: Argument "order" to "partition" has incompatible type
  29. )
  30. np.argpartition(
  31. a, None # E: incompatible type
  32. )
  33. np.argpartition(
  34. a, 0, axis="bob" # E: incompatible type
  35. )
  36. np.argpartition(
  37. A, 0, kind="bob" # E: incompatible type
  38. )
  39. np.argpartition(
  40. A, 0, order=range(5) # E: Argument "order" to "argpartition" has incompatible type
  41. )
  42. np.sort(A, axis="bob") # E: Argument "axis" to "sort" has incompatible type
  43. np.sort(A, kind="bob") # E: Argument "kind" to "sort" has incompatible type
  44. np.sort(A, order=range(5)) # E: Argument "order" to "sort" has incompatible type
  45. np.argsort(A, axis="bob") # E: Argument "axis" to "argsort" has incompatible type
  46. np.argsort(A, kind="bob") # E: Argument "kind" to "argsort" has incompatible type
  47. np.argsort(A, order=range(5)) # E: Argument "order" to "argsort" has incompatible type
  48. np.argmax(A, axis="bob") # E: No overload variant of "argmax" matches argument type
  49. np.argmax(A, kind="bob") # E: No overload variant of "argmax" matches argument type
  50. np.argmin(A, axis="bob") # E: No overload variant of "argmin" matches argument type
  51. np.argmin(A, kind="bob") # E: No overload variant of "argmin" matches argument type
  52. np.searchsorted( # E: No overload variant of "searchsorted" matches argument type
  53. A[0], 0, side="bob"
  54. )
  55. np.searchsorted( # E: No overload variant of "searchsorted" matches argument type
  56. A[0], 0, sorter=1.0
  57. )
  58. np.resize(A, 1.0) # E: Argument 2 to "resize" has incompatible type
  59. np.squeeze(A, 1.0) # E: No overload variant of "squeeze" matches argument type
  60. np.diagonal(A, offset=None) # E: Argument "offset" to "diagonal" has incompatible type
  61. np.diagonal(A, axis1="bob") # E: Argument "axis1" to "diagonal" has incompatible type
  62. np.diagonal(A, axis2=[]) # E: Argument "axis2" to "diagonal" has incompatible type
  63. np.trace(A, offset=None) # E: Argument "offset" to "trace" has incompatible type
  64. np.trace(A, axis1="bob") # E: Argument "axis1" to "trace" has incompatible type
  65. np.trace(A, axis2=[]) # E: Argument "axis2" to "trace" has incompatible type
  66. np.ravel(a, order="bob") # E: Argument "order" to "ravel" has incompatible type
  67. np.compress(
  68. [True], A, axis=1.0 # E: Argument "axis" to "compress" has incompatible type
  69. )
  70. np.clip(a, 1, 2, out=1) # E: No overload variant of "clip" matches argument type
  71. np.clip(1, None, None) # E: No overload variant of "clip" matches argument type
  72. np.sum(a, axis=1.0) # E: incompatible type
  73. np.sum(a, keepdims=1.0) # E: incompatible type
  74. np.sum(a, initial=[1]) # E: incompatible type
  75. np.all(a, axis=1.0) # E: No overload variant
  76. np.all(a, keepdims=1.0) # E: No overload variant
  77. np.all(a, out=1.0) # E: No overload variant
  78. np.any(a, axis=1.0) # E: No overload variant
  79. np.any(a, keepdims=1.0) # E: No overload variant
  80. np.any(a, out=1.0) # E: No overload variant
  81. np.cumsum(a, axis=1.0) # E: incompatible type
  82. np.cumsum(a, dtype=1.0) # E: incompatible type
  83. np.cumsum(a, out=1.0) # E: incompatible type
  84. np.ptp(a, axis=1.0) # E: incompatible type
  85. np.ptp(a, keepdims=1.0) # E: incompatible type
  86. np.ptp(a, out=1.0) # E: incompatible type
  87. np.amax(a, axis=1.0) # E: incompatible type
  88. np.amax(a, keepdims=1.0) # E: incompatible type
  89. np.amax(a, out=1.0) # E: incompatible type
  90. np.amax(a, initial=[1.0]) # E: incompatible type
  91. np.amax(a, where=[1.0]) # E: List item 0 has incompatible type
  92. np.amin(a, axis=1.0) # E: incompatible type
  93. np.amin(a, keepdims=1.0) # E: incompatible type
  94. np.amin(a, out=1.0) # E: incompatible type
  95. np.amin(a, initial=[1.0]) # E: incompatible type
  96. np.amin(a, where=[1.0]) # E: List item 0 has incompatible type
  97. np.prod(a, axis=1.0) # E: incompatible type
  98. np.prod(a, out=False) # E: incompatible type
  99. np.prod(a, keepdims=1.0) # E: incompatible type
  100. np.prod(a, initial=int) # E: incompatible type
  101. np.prod(a, where=1.0) # E: incompatible type
  102. np.cumprod(a, axis=1.0) # E: Argument "axis" to "cumprod" has incompatible type
  103. np.cumprod(a, out=False) # E: Argument "out" to "cumprod" has incompatible type
  104. np.size(a, axis=1.0) # E: Argument "axis" to "size" has incompatible type
  105. np.around(a, decimals=1.0) # E: incompatible type
  106. np.around(a, out=type) # E: incompatible type
  107. np.mean(a, axis=1.0) # E: incompatible type
  108. np.mean(a, out=False) # E: incompatible type
  109. np.mean(a, keepdims=1.0) # E: incompatible type
  110. np.std(a, axis=1.0) # E: incompatible type
  111. np.std(a, out=False) # E: incompatible type
  112. np.std(a, ddof='test') # E: incompatible type
  113. np.std(a, keepdims=1.0) # E: incompatible type
  114. np.var(a, axis=1.0) # E: incompatible type
  115. np.var(a, out=False) # E: incompatible type
  116. np.var(a, ddof='test') # E: incompatible type
  117. np.var(a, keepdims=1.0) # E: incompatible type