numpy 2.3.3__cp312-cp312-win_amd64.whl → 2.3.4__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of numpy might be problematic. Click here for more details.

Files changed (78) hide show
  1. numpy/__config__.py +8 -8
  2. numpy/__init__.pyi +819 -218
  3. numpy/_core/_multiarray_tests.cp312-win_amd64.lib +0 -0
  4. numpy/_core/_multiarray_tests.cp312-win_amd64.pyd +0 -0
  5. numpy/_core/_multiarray_umath.cp312-win_amd64.lib +0 -0
  6. numpy/_core/_multiarray_umath.cp312-win_amd64.pyd +0 -0
  7. numpy/_core/_operand_flag_tests.cp312-win_amd64.lib +0 -0
  8. numpy/_core/_operand_flag_tests.cp312-win_amd64.pyd +0 -0
  9. numpy/_core/_rational_tests.cp312-win_amd64.lib +0 -0
  10. numpy/_core/_rational_tests.cp312-win_amd64.pyd +0 -0
  11. numpy/_core/_simd.cp312-win_amd64.lib +0 -0
  12. numpy/_core/_simd.cp312-win_amd64.pyd +0 -0
  13. numpy/_core/_struct_ufunc_tests.cp312-win_amd64.lib +0 -0
  14. numpy/_core/_struct_ufunc_tests.cp312-win_amd64.pyd +0 -0
  15. numpy/_core/_ufunc_config.py +2 -0
  16. numpy/_core/_ufunc_config.pyi +52 -6
  17. numpy/_core/_umath_tests.cp312-win_amd64.lib +0 -0
  18. numpy/_core/_umath_tests.cp312-win_amd64.pyd +0 -0
  19. numpy/_core/lib/npymath.lib +0 -0
  20. numpy/_core/lib/pkgconfig/numpy.pc +1 -1
  21. numpy/_core/numerictypes.py +1 -1
  22. numpy/_core/tests/test_api.py +34 -1
  23. numpy/_core/tests/test_numerictypes.py +29 -0
  24. numpy/_core/tests/test_stringdtype.py +16 -16
  25. numpy/_core/tests/test_strings.py +15 -0
  26. numpy/_core/tests/test_umath.py +12 -0
  27. numpy/exceptions.pyi +2 -0
  28. numpy/fft/_pocketfft_umath.cp312-win_amd64.lib +0 -0
  29. numpy/fft/_pocketfft_umath.cp312-win_amd64.pyd +0 -0
  30. numpy/lib/_histograms_impl.pyi +8 -8
  31. numpy/lib/_index_tricks_impl.pyi +12 -0
  32. numpy/lib/_polynomial_impl.pyi +10 -8
  33. numpy/lib/mixins.pyi +2 -0
  34. numpy/lib/tests/test_index_tricks.py +5 -0
  35. numpy/linalg/_linalg.pyi +32 -39
  36. numpy/linalg/_umath_linalg.cp312-win_amd64.lib +0 -0
  37. numpy/linalg/_umath_linalg.cp312-win_amd64.pyd +0 -0
  38. numpy/linalg/lapack_lite.cp312-win_amd64.lib +0 -0
  39. numpy/linalg/lapack_lite.cp312-win_amd64.pyd +0 -0
  40. numpy/ma/extras.pyi +4 -0
  41. numpy/random/_bounded_integers.cp312-win_amd64.lib +0 -0
  42. numpy/random/_bounded_integers.cp312-win_amd64.pyd +0 -0
  43. numpy/random/_common.cp312-win_amd64.lib +0 -0
  44. numpy/random/_common.cp312-win_amd64.pyd +0 -0
  45. numpy/random/_generator.cp312-win_amd64.lib +0 -0
  46. numpy/random/_generator.cp312-win_amd64.pyd +0 -0
  47. numpy/random/_mt19937.cp312-win_amd64.lib +0 -0
  48. numpy/random/_mt19937.cp312-win_amd64.pyd +0 -0
  49. numpy/random/_pcg64.cp312-win_amd64.lib +0 -0
  50. numpy/random/_pcg64.cp312-win_amd64.pyd +0 -0
  51. numpy/random/_philox.cp312-win_amd64.lib +0 -0
  52. numpy/random/_philox.cp312-win_amd64.pyd +0 -0
  53. numpy/random/_sfc64.cp312-win_amd64.lib +0 -0
  54. numpy/random/_sfc64.cp312-win_amd64.pyd +0 -0
  55. numpy/random/bit_generator.cp312-win_amd64.lib +0 -0
  56. numpy/random/bit_generator.cp312-win_amd64.pyd +0 -0
  57. numpy/random/lib/npyrandom.lib +0 -0
  58. numpy/random/mtrand.cp312-win_amd64.lib +0 -0
  59. numpy/random/mtrand.cp312-win_amd64.pyd +0 -0
  60. numpy/random/tests/test_generator_mt19937.py +5 -0
  61. numpy/testing/_private/extbuild.pyi +3 -3
  62. numpy/testing/_private/utils.pyi +1 -1
  63. numpy/typing/tests/data/fail/bitwise_ops.pyi +3 -3
  64. numpy/typing/tests/data/fail/scalars.pyi +6 -6
  65. numpy/typing/tests/data/reveal/arithmetic.pyi +29 -29
  66. numpy/typing/tests/data/reveal/array_constructors.pyi +5 -5
  67. numpy/typing/tests/data/reveal/bitwise_ops.pyi +10 -11
  68. numpy/typing/tests/data/reveal/linalg.pyi +6 -6
  69. numpy/typing/tests/data/reveal/mod.pyi +18 -19
  70. numpy/version.py +2 -2
  71. numpy-2.3.4.dist-info/DELVEWHEEL +2 -0
  72. {numpy-2.3.3.dist-info → numpy-2.3.4.dist-info}/METADATA +1 -1
  73. {numpy-2.3.3.dist-info → numpy-2.3.4.dist-info}/RECORD +76 -77
  74. numpy/_typing/_callable.pyi +0 -279
  75. numpy-2.3.3.dist-info/DELVEWHEEL +0 -2
  76. {numpy-2.3.3.dist-info → numpy-2.3.4.dist-info}/LICENSE.txt +0 -0
  77. {numpy-2.3.3.dist-info → numpy-2.3.4.dist-info}/WHEEL +0 -0
  78. {numpy-2.3.3.dist-info → numpy-2.3.4.dist-info}/entry_points.txt +0 -0
Binary file
Binary file
@@ -187,6 +187,8 @@ def setbufsize(size):
187
187
  8192
188
188
 
189
189
  """
190
+ if size < 0:
191
+ raise ValueError("buffer size must be non-negative")
190
192
  old = _get_extobj_dict()["bufsize"]
191
193
  extobj = _make_extobj(bufsize=size)
192
194
  _extobj_contextvar.set(extobj)
@@ -1,13 +1,31 @@
1
1
  from collections.abc import Callable
2
- from typing import Any, Literal, TypeAlias, TypedDict, type_check_only
2
+ from types import TracebackType
3
+ from typing import (
4
+ Any,
5
+ Final,
6
+ Literal,
7
+ TypeAlias,
8
+ TypedDict,
9
+ TypeVar,
10
+ type_check_only,
11
+ )
3
12
 
4
13
  from _typeshed import SupportsWrite
5
14
 
6
- from numpy import errstate as errstate
15
+ __all__ = [
16
+ "seterr",
17
+ "geterr",
18
+ "setbufsize",
19
+ "getbufsize",
20
+ "seterrcall",
21
+ "geterrcall",
22
+ "errstate",
23
+ ]
7
24
 
8
25
  _ErrKind: TypeAlias = Literal["ignore", "warn", "raise", "call", "print", "log"]
9
- _ErrFunc: TypeAlias = Callable[[str, int], Any]
10
- _ErrCall: TypeAlias = _ErrFunc | SupportsWrite[str]
26
+ _ErrCall: TypeAlias = Callable[[str, int], Any] | SupportsWrite[str]
27
+
28
+ _CallableT = TypeVar("_CallableT", bound=Callable[..., object])
11
29
 
12
30
  @type_check_only
13
31
  class _ErrDict(TypedDict):
@@ -16,6 +34,36 @@ class _ErrDict(TypedDict):
16
34
  under: _ErrKind
17
35
  invalid: _ErrKind
18
36
 
37
+ ###
38
+
39
+ class _unspecified: ...
40
+
41
+ _Unspecified: Final[_unspecified]
42
+
43
+ class errstate:
44
+ __slots__ = "_all", "_call", "_divide", "_invalid", "_over", "_token", "_under"
45
+
46
+ def __init__(
47
+ self,
48
+ /,
49
+ *,
50
+ call: _ErrCall | _unspecified = ..., # = _Unspecified
51
+ all: _ErrKind | None = None,
52
+ divide: _ErrKind | None = None,
53
+ over: _ErrKind | None = None,
54
+ under: _ErrKind | None = None,
55
+ invalid: _ErrKind | None = None,
56
+ ) -> None: ...
57
+ def __call__(self, /, func: _CallableT) -> _CallableT: ...
58
+ def __enter__(self) -> None: ...
59
+ def __exit__(
60
+ self,
61
+ exc_type: type[BaseException] | None,
62
+ exc_value: BaseException | None,
63
+ traceback: TracebackType | None,
64
+ /,
65
+ ) -> None: ...
66
+
19
67
  def seterr(
20
68
  all: _ErrKind | None = ...,
21
69
  divide: _ErrKind | None = ...,
@@ -28,5 +76,3 @@ def setbufsize(size: int) -> int: ...
28
76
  def getbufsize() -> int: ...
29
77
  def seterrcall(func: _ErrCall | None) -> _ErrCall | None: ...
30
78
  def geterrcall() -> _ErrCall | None: ...
31
-
32
- # See `numpy/__init__.pyi` for the `errstate` class and `no_nep5_warnings`
Binary file
@@ -3,5 +3,5 @@ includedir=${prefix}/include
3
3
 
4
4
  Name: numpy
5
5
  Description: NumPy is the fundamental package for scientific computing with Python.
6
- Version: 2.3.3
6
+ Version: 2.3.4
7
7
  Cflags: -I${includedir}
@@ -598,7 +598,7 @@ def _scalar_type_key(typ):
598
598
 
599
599
 
600
600
  ScalarType = [int, float, complex, bool, bytes, str, memoryview]
601
- ScalarType += sorted(set(sctypeDict.values()), key=_scalar_type_key)
601
+ ScalarType += sorted(dict.fromkeys(sctypeDict.values()), key=_scalar_type_key)
602
602
  ScalarType = tuple(ScalarType)
603
603
 
604
604
 
@@ -91,7 +91,7 @@ def test_array_array():
91
91
  # instead we get a array([...], dtype=">V18")
92
92
  assert_equal(bytes(np.array(o).data), bytes(a.data))
93
93
 
94
- # test array
94
+ # test __array__
95
95
  def custom__array__(self, dtype=None, copy=None):
96
96
  return np.array(100.0, dtype=dtype, copy=copy)
97
97
 
@@ -157,6 +157,39 @@ def test_array_array():
157
157
  assert_equal(np.array([(1.0,) * 10] * 10, dtype=np.float64),
158
158
  np.ones((10, 10), dtype=np.float64))
159
159
 
160
+
161
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
162
+ def test___array___refcount():
163
+ class MyArray:
164
+ def __init__(self, dtype):
165
+ self.val = np.array(-1, dtype=dtype)
166
+
167
+ def __array__(self, dtype=None, copy=None):
168
+ return self.val.__array__(dtype=dtype, copy=copy)
169
+
170
+ # test all possible scenarios:
171
+ # dtype(none | same | different) x copy(true | false | none)
172
+ dt = np.dtype(np.int32)
173
+ old_refcount = sys.getrefcount(dt)
174
+ np.array(MyArray(dt))
175
+ assert_equal(old_refcount, sys.getrefcount(dt))
176
+ np.array(MyArray(dt), dtype=dt)
177
+ assert_equal(old_refcount, sys.getrefcount(dt))
178
+ np.array(MyArray(dt), copy=None)
179
+ assert_equal(old_refcount, sys.getrefcount(dt))
180
+ np.array(MyArray(dt), dtype=dt, copy=None)
181
+ assert_equal(old_refcount, sys.getrefcount(dt))
182
+ dt2 = np.dtype(np.int16)
183
+ old_refcount2 = sys.getrefcount(dt2)
184
+ np.array(MyArray(dt), dtype=dt2)
185
+ assert_equal(old_refcount2, sys.getrefcount(dt2))
186
+ np.array(MyArray(dt), dtype=dt2, copy=None)
187
+ assert_equal(old_refcount2, sys.getrefcount(dt2))
188
+ with pytest.raises(ValueError):
189
+ np.array(MyArray(dt), dtype=dt2, copy=False)
190
+ assert_equal(old_refcount2, sys.getrefcount(dt2))
191
+
192
+
160
193
  @pytest.mark.parametrize("array", [True, False])
161
194
  def test_array_impossible_casts(array):
162
195
  # All builtin types can be forcibly cast, at least theoretically,
@@ -617,6 +617,35 @@ class TestScalarTypeNames:
617
617
  assert np.dtype(t.__name__).type is t
618
618
 
619
619
 
620
+ class TestScalarTypeOrder:
621
+ @pytest.mark.parametrize(('a', 'b'), [
622
+ # signedinteger
623
+ (np.byte, np.short),
624
+ (np.short, np.intc),
625
+ (np.intc, np.long),
626
+ (np.long, np.longlong),
627
+ # unsignedinteger
628
+ (np.ubyte, np.ushort),
629
+ (np.ushort, np.uintc),
630
+ (np.uintc, np.ulong),
631
+ (np.ulong, np.ulonglong),
632
+ # floating
633
+ (np.half, np.single),
634
+ (np.single, np.double),
635
+ (np.double, np.longdouble),
636
+ # complexfloating
637
+ (np.csingle, np.cdouble),
638
+ (np.cdouble, np.clongdouble),
639
+ # flexible
640
+ (np.bytes_, np.str_),
641
+ (np.str_, np.void),
642
+ # bouncy castles
643
+ (np.datetime64, np.timedelta64),
644
+ ])
645
+ def test_stable_ordering(self, a: type[np.generic], b: type[np.generic]):
646
+ assert np.ScalarType.index(a) <= np.ScalarType.index(b)
647
+
648
+
620
649
  class TestBoolDefinition:
621
650
  def test_bool_definition(self):
622
651
  assert nt.bool is np.bool
@@ -1631,17 +1631,17 @@ class TestImplementation:
1631
1631
  """
1632
1632
 
1633
1633
  @classmethod
1634
- def setup_class(self):
1635
- self.MISSING = 0x80
1636
- self.INITIALIZED = 0x40
1637
- self.OUTSIDE_ARENA = 0x20
1638
- self.LONG = 0x10
1639
- self.dtype = StringDType(na_object=np.nan)
1640
- self.sizeofstr = self.dtype.itemsize
1641
- sp = self.dtype.itemsize // 2 # pointer size = sizeof(size_t)
1634
+ def setup_class(cls):
1635
+ cls.MISSING = 0x80
1636
+ cls.INITIALIZED = 0x40
1637
+ cls.OUTSIDE_ARENA = 0x20
1638
+ cls.LONG = 0x10
1639
+ cls.dtype = StringDType(na_object=np.nan)
1640
+ cls.sizeofstr = cls.dtype.itemsize
1641
+ sp = cls.dtype.itemsize // 2 # pointer size = sizeof(size_t)
1642
1642
  # Below, size is not strictly correct, since it really uses
1643
1643
  # 7 (or 3) bytes, but good enough for the tests here.
1644
- self.view_dtype = np.dtype([
1644
+ cls.view_dtype = np.dtype([
1645
1645
  ('offset', f'u{sp}'),
1646
1646
  ('size', f'u{sp // 2}'),
1647
1647
  ('xsiz', f'V{sp // 2 - 1}'),
@@ -1652,13 +1652,13 @@ class TestImplementation:
1652
1652
  ('size', f'u{sp // 2}'),
1653
1653
  ('offset', f'u{sp}'),
1654
1654
  ])
1655
- self.s_empty = ""
1656
- self.s_short = "01234"
1657
- self.s_medium = "abcdefghijklmnopqrstuvwxyz"
1658
- self.s_long = "-=+" * 100
1659
- self.a = np.array(
1660
- [self.s_empty, self.s_short, self.s_medium, self.s_long],
1661
- self.dtype)
1655
+ cls.s_empty = ""
1656
+ cls.s_short = "01234"
1657
+ cls.s_medium = "abcdefghijklmnopqrstuvwxyz"
1658
+ cls.s_long = "-=+" * 100
1659
+ cls.a = np.array(
1660
+ [cls.s_empty, cls.s_short, cls.s_medium, cls.s_long],
1661
+ cls.dtype)
1662
1662
 
1663
1663
  def get_view(self, a):
1664
1664
  # Cannot view a StringDType as anything else directly, since
@@ -4,6 +4,7 @@ import sys
4
4
  import pytest
5
5
 
6
6
  import numpy as np
7
+ from numpy._core._exceptions import _UFuncNoLoopError
7
8
  from numpy.testing import IS_PYPY, assert_array_equal, assert_raises
8
9
  from numpy.testing._private.utils import requires_memory
9
10
 
@@ -821,6 +822,20 @@ class TestMethods:
821
822
  np.strings.expandtabs(np.array("\ta\n\tb", dtype=dt), sys.maxsize)
822
823
  np.strings.expandtabs(np.array("\ta\n\tb", dtype=dt), 2**61)
823
824
 
825
+ def test_expandtabs_length_not_cause_segfault(self, dt):
826
+ # see gh-28829
827
+ with pytest.raises(
828
+ _UFuncNoLoopError,
829
+ match="did not contain a loop with signature matching types",
830
+ ):
831
+ np._core.strings._expandtabs_length.reduce(np.zeros(200))
832
+
833
+ with pytest.raises(
834
+ _UFuncNoLoopError,
835
+ match="did not contain a loop with signature matching types",
836
+ ):
837
+ np.strings.expandtabs(np.zeros(200))
838
+
824
839
  FILL_ERROR = "The fill character must be exactly one character long"
825
840
 
826
841
  def test_center_raises_multiple_character_fill(self, dt):
@@ -4704,6 +4704,18 @@ def test_reduceat():
4704
4704
  np.setbufsize(ncu.UFUNC_BUFSIZE_DEFAULT)
4705
4705
  assert_array_almost_equal(h1, h2)
4706
4706
 
4707
+ def test_negative_value_raises():
4708
+ with pytest.raises(ValueError, match="buffer size must be non-negative"):
4709
+ np.setbufsize(-5)
4710
+
4711
+ old = np.getbufsize()
4712
+ try:
4713
+ prev = np.setbufsize(4096)
4714
+ assert prev == old
4715
+ assert np.getbufsize() == 4096
4716
+ finally:
4717
+ np.setbufsize(old)
4718
+
4707
4719
  def test_reduceat_empty():
4708
4720
  """Reduceat should work with empty arrays"""
4709
4721
  indices = np.array([], 'i4')
numpy/exceptions.pyi CHANGED
@@ -17,6 +17,8 @@ class TooHardError(RuntimeError): ...
17
17
  class DTypePromotionError(TypeError): ...
18
18
 
19
19
  class AxisError(ValueError, IndexError):
20
+ __slots__ = "_msg", "axis", "ndim"
21
+
20
22
  axis: int | None
21
23
  ndim: int | None
22
24
  @overload
@@ -35,16 +35,16 @@ def histogram_bin_edges(
35
35
 
36
36
  def histogram(
37
37
  a: ArrayLike,
38
- bins: _BinKind | SupportsIndex | ArrayLike = ...,
39
- range: tuple[float, float] | None = ...,
40
- density: bool = ...,
41
- weights: ArrayLike | None = ...,
38
+ bins: _BinKind | SupportsIndex | ArrayLike = 10,
39
+ range: tuple[float, float] | None = None,
40
+ density: bool | None = None,
41
+ weights: ArrayLike | None = None,
42
42
  ) -> tuple[NDArray[Any], NDArray[Any]]: ...
43
43
 
44
44
  def histogramdd(
45
45
  sample: ArrayLike,
46
- bins: SupportsIndex | ArrayLike = ...,
47
- range: Sequence[tuple[float, float]] = ...,
48
- density: bool | None = ...,
49
- weights: ArrayLike | None = ...,
46
+ bins: SupportsIndex | ArrayLike = 10,
47
+ range: Sequence[tuple[float, float]] | None = None,
48
+ density: bool | None = None,
49
+ weights: ArrayLike | None = None,
50
50
  ) -> tuple[NDArray[Any], tuple[NDArray[Any], ...]]: ...
@@ -98,6 +98,8 @@ class ndindex:
98
98
  def ndincr(self, /) -> None: ...
99
99
 
100
100
  class nd_grid(Generic[_BoolT_co]):
101
+ __slots__ = ("sparse",)
102
+
101
103
  sparse: _BoolT_co
102
104
  def __init__(self, sparse: _BoolT_co = ...) -> None: ...
103
105
  @overload
@@ -107,10 +109,14 @@ class nd_grid(Generic[_BoolT_co]):
107
109
 
108
110
  @final
109
111
  class MGridClass(nd_grid[L[False]]):
112
+ __slots__ = ()
113
+
110
114
  def __init__(self) -> None: ...
111
115
 
112
116
  @final
113
117
  class OGridClass(nd_grid[L[True]]):
118
+ __slots__ = ()
119
+
114
120
  def __init__(self) -> None: ...
115
121
 
116
122
  class AxisConcatenator(Generic[_AxisT_co, _MatrixT_co, _NDMinT_co, _Trans1DT_co]):
@@ -147,13 +153,19 @@ class AxisConcatenator(Generic[_AxisT_co, _MatrixT_co, _NDMinT_co, _Trans1DT_co]
147
153
 
148
154
  @final
149
155
  class RClass(AxisConcatenator[L[0], L[False], L[1], L[-1]]):
156
+ __slots__ = ()
157
+
150
158
  def __init__(self, /) -> None: ...
151
159
 
152
160
  @final
153
161
  class CClass(AxisConcatenator[L[-1], L[False], L[2], L[0]]):
162
+ __slots__ = ()
163
+
154
164
  def __init__(self, /) -> None: ...
155
165
 
156
166
  class IndexExpression(Generic[_BoolT_co]):
167
+ __slots__ = ("maketuple",)
168
+
157
169
  maketuple: _BoolT_co
158
170
  def __init__(self, maketuple: _BoolT_co) -> None: ...
159
171
  @overload
@@ -137,20 +137,22 @@ def polyfit(
137
137
  x: _ArrayLikeFloat_co,
138
138
  y: _ArrayLikeFloat_co,
139
139
  deg: SupportsIndex | SupportsInt,
140
- rcond: float | None = ...,
141
- full: L[False] = ...,
142
- w: _ArrayLikeFloat_co | None = ...,
143
- cov: L[True, "unscaled"] = ...,
140
+ rcond: float | None = None,
141
+ full: L[False] = False,
142
+ w: _ArrayLikeFloat_co | None = None,
143
+ *,
144
+ cov: L[True, "unscaled"],
144
145
  ) -> _2Tup[NDArray[float64]]: ...
145
146
  @overload
146
147
  def polyfit(
147
148
  x: _ArrayLikeComplex_co,
148
149
  y: _ArrayLikeComplex_co,
149
150
  deg: SupportsIndex | SupportsInt,
150
- rcond: float | None = ...,
151
- full: L[False] = ...,
152
- w: _ArrayLikeFloat_co | None = ...,
153
- cov: L[True, "unscaled"] = ...,
151
+ rcond: float | None = None,
152
+ full: L[False] = False,
153
+ w: _ArrayLikeFloat_co | None = None,
154
+ *,
155
+ cov: L[True, "unscaled"],
154
156
  ) -> _2Tup[NDArray[complex128]]: ...
155
157
  @overload
156
158
  def polyfit(
numpy/lib/mixins.pyi CHANGED
@@ -14,6 +14,8 @@ __all__ = ["NDArrayOperatorsMixin"]
14
14
  # As such, only little type safety can be provided here.
15
15
 
16
16
  class NDArrayOperatorsMixin(ABC):
17
+ __slots__ = ()
18
+
17
19
  @abstractmethod
18
20
  def __array_ufunc__(
19
21
  self,
@@ -199,6 +199,11 @@ class TestRavelUnravelIndex:
199
199
  with assert_raises(ValueError):
200
200
  np.unravel_index([1], (2, 1, 0))
201
201
 
202
+ def test_regression_size_1_index(self):
203
+ # actually tests the nditer size one index tracking
204
+ # regression test for gh-29690
205
+ np.unravel_index(np.array([[1, 0, 1, 0]], dtype=np.uint32), (4,))
206
+
202
207
  class TestGrid:
203
208
  def test_basic(self):
204
209
  a = mgrid[-1:1:10j]
numpy/linalg/_linalg.pyi CHANGED
@@ -28,6 +28,7 @@ from numpy import (
28
28
  )
29
29
  from numpy._core.fromnumeric import matrix_transpose
30
30
  from numpy._core.numeric import tensordot
31
+ from numpy._globals import _NoValueType
31
32
  from numpy._typing import (
32
33
  ArrayLike,
33
34
  DTypeLike,
@@ -78,7 +79,7 @@ __all__ = [
78
79
  "vecdot",
79
80
  ]
80
81
 
81
- _ArrayT = TypeVar("_ArrayT", bound=NDArray[Any])
82
+ _NumberT = TypeVar("_NumberT", bound=np.number)
82
83
 
83
84
  _ModeKind: TypeAlias = L["reduced", "complete", "r", "raw"]
84
85
 
@@ -182,33 +183,29 @@ def cholesky(a: _ArrayLikeFloat_co, /, *, upper: bool = False) -> NDArray[floati
182
183
  def cholesky(a: _ArrayLikeComplex_co, /, *, upper: bool = False) -> NDArray[complexfloating]: ...
183
184
 
184
185
  @overload
185
- def outer(x1: _ArrayLike[Never], x2: _ArrayLike[Never]) -> NDArray[Any]: ...
186
+ def outer(x1: _ArrayLike[Never], x2: _ArrayLike[Never], /) -> NDArray[Any]: ...
186
187
  @overload
187
- def outer(x1: _ArrayLikeBool_co, x2: _ArrayLikeBool_co) -> NDArray[np.bool]: ...
188
+ def outer(x1: _ArrayLikeBool_co, x2: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ...
188
189
  @overload
189
- def outer(x1: _ArrayLikeUInt_co, x2: _ArrayLikeUInt_co) -> NDArray[unsignedinteger]: ...
190
+ def outer(x1: _ArrayLike[_NumberT], x2: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ...
190
191
  @overload
191
- def outer(x1: _ArrayLikeInt_co, x2: _ArrayLikeInt_co) -> NDArray[signedinteger]: ...
192
+ def outer(x1: _ArrayLikeUInt_co, x2: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ...
192
193
  @overload
193
- def outer(x1: _ArrayLikeFloat_co, x2: _ArrayLikeFloat_co) -> NDArray[floating]: ...
194
+ def outer(x1: _ArrayLikeInt_co, x2: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
194
195
  @overload
195
- def outer(
196
- x1: _ArrayLikeComplex_co,
197
- x2: _ArrayLikeComplex_co,
198
- ) -> NDArray[complexfloating]: ...
196
+ def outer(x1: _ArrayLikeFloat_co, x2: _ArrayLikeFloat_co, /) -> NDArray[floating]: ...
199
197
  @overload
200
- def outer(
201
- x1: _ArrayLikeTD64_co,
202
- x2: _ArrayLikeTD64_co,
203
- out: None = ...,
204
- ) -> NDArray[timedelta64]: ...
198
+ def outer(x1: _ArrayLikeComplex_co, x2: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ...
199
+ @overload
200
+ def outer(x1: _ArrayLikeTD64_co, x2: _ArrayLikeTD64_co, /) -> NDArray[timedelta64]: ...
205
201
  @overload
206
- def outer(x1: _ArrayLikeObject_co, x2: _ArrayLikeObject_co) -> NDArray[object_]: ...
202
+ def outer(x1: _ArrayLikeObject_co, x2: _ArrayLikeObject_co, /) -> NDArray[object_]: ...
207
203
  @overload
208
204
  def outer(
209
205
  x1: _ArrayLikeComplex_co | _ArrayLikeTD64_co | _ArrayLikeObject_co,
210
206
  x2: _ArrayLikeComplex_co | _ArrayLikeTD64_co | _ArrayLikeObject_co,
211
- ) -> _ArrayT: ...
207
+ /,
208
+ ) -> NDArray[Any]: ...
212
209
 
213
210
  @overload
214
211
  def qr(a: _ArrayLikeInt_co, mode: _ModeKind = ...) -> QRResult: ...
@@ -308,20 +305,26 @@ def matrix_rank(
308
305
  @overload
309
306
  def pinv(
310
307
  a: _ArrayLikeInt_co,
311
- rcond: _ArrayLikeFloat_co = ...,
312
- hermitian: bool = ...,
308
+ rcond: _ArrayLikeFloat_co | None = None,
309
+ hermitian: bool = False,
310
+ *,
311
+ rtol: _ArrayLikeFloat_co | _NoValueType = ...,
313
312
  ) -> NDArray[float64]: ...
314
313
  @overload
315
314
  def pinv(
316
315
  a: _ArrayLikeFloat_co,
317
- rcond: _ArrayLikeFloat_co = ...,
318
- hermitian: bool = ...,
316
+ rcond: _ArrayLikeFloat_co | None = None,
317
+ hermitian: bool = False,
318
+ *,
319
+ rtol: _ArrayLikeFloat_co | _NoValueType = ...,
319
320
  ) -> NDArray[floating]: ...
320
321
  @overload
321
322
  def pinv(
322
323
  a: _ArrayLikeComplex_co,
323
- rcond: _ArrayLikeFloat_co = ...,
324
- hermitian: bool = ...,
324
+ rcond: _ArrayLikeFloat_co | None = None,
325
+ hermitian: bool = False,
326
+ *,
327
+ rtol: _ArrayLikeFloat_co | _NoValueType = ...,
325
328
  ) -> NDArray[complexfloating]: ...
326
329
 
327
330
  # TODO: Returns a 2-tuple of scalars for 2D arrays and
@@ -461,22 +464,12 @@ def cross(
461
464
  ) -> NDArray[complexfloating]: ...
462
465
 
463
466
  @overload
464
- def matmul(
465
- x1: _ArrayLikeInt_co,
466
- x2: _ArrayLikeInt_co,
467
- ) -> NDArray[signedinteger]: ...
467
+ def matmul(x1: _ArrayLike[_NumberT], x2: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ...
468
468
  @overload
469
- def matmul(
470
- x1: _ArrayLikeUInt_co,
471
- x2: _ArrayLikeUInt_co,
472
- ) -> NDArray[unsignedinteger]: ...
469
+ def matmul(x1: _ArrayLikeInt_co, x2: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
473
470
  @overload
474
- def matmul(
475
- x1: _ArrayLikeFloat_co,
476
- x2: _ArrayLikeFloat_co,
477
- ) -> NDArray[floating]: ...
471
+ def matmul(x1: _ArrayLikeUInt_co, x2: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ...
478
472
  @overload
479
- def matmul(
480
- x1: _ArrayLikeComplex_co,
481
- x2: _ArrayLikeComplex_co,
482
- ) -> NDArray[complexfloating]: ...
473
+ def matmul(x1: _ArrayLikeFloat_co, x2: _ArrayLikeFloat_co, /) -> NDArray[floating]: ...
474
+ @overload
475
+ def matmul(x1: _ArrayLikeComplex_co, x2: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ...
numpy/ma/extras.pyi CHANGED
@@ -110,12 +110,16 @@ def cov(x, y=..., rowvar=..., bias=..., allow_masked=..., ddof=...): ...
110
110
  def corrcoef(x, y=..., rowvar=..., bias=..., allow_masked=..., ddof=...): ...
111
111
 
112
112
  class MAxisConcatenator(AxisConcatenator):
113
+ __slots__ = ()
114
+
113
115
  @staticmethod
114
116
  def concatenate(arrays: Incomplete, axis: int = 0) -> Incomplete: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
115
117
  @classmethod
116
118
  def makemat(cls, arr: Incomplete) -> Incomplete: ... # type: ignore[override] # pyright: ignore[reportIncompatibleVariableOverride]
117
119
 
118
120
  class mr_class(MAxisConcatenator):
121
+ __slots__ = ()
122
+
119
123
  def __init__(self) -> None: ...
120
124
 
121
125
  mr_: mr_class
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file