numpy 2.3.2__cp313-cp313t-win_amd64.whl → 2.3.3__cp313-cp313t-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 (61) hide show
  1. numpy/__config__.py +10 -10
  2. numpy/__init__.py +4 -4
  3. numpy/__init__.pyi +189 -29
  4. numpy/_core/_multiarray_tests.cp313t-win_amd64.lib +0 -0
  5. numpy/_core/_multiarray_tests.cp313t-win_amd64.pyd +0 -0
  6. numpy/_core/_multiarray_umath.cp313t-win_amd64.lib +0 -0
  7. numpy/_core/_multiarray_umath.cp313t-win_amd64.pyd +0 -0
  8. numpy/_core/_operand_flag_tests.cp313t-win_amd64.lib +0 -0
  9. numpy/_core/_operand_flag_tests.cp313t-win_amd64.pyd +0 -0
  10. numpy/_core/_rational_tests.cp313t-win_amd64.lib +0 -0
  11. numpy/_core/_rational_tests.cp313t-win_amd64.pyd +0 -0
  12. numpy/_core/_simd.cp313t-win_amd64.lib +0 -0
  13. numpy/_core/_simd.cp313t-win_amd64.pyd +0 -0
  14. numpy/_core/_struct_ufunc_tests.cp313t-win_amd64.lib +0 -0
  15. numpy/_core/_struct_ufunc_tests.cp313t-win_amd64.pyd +0 -0
  16. numpy/_core/_umath_tests.cp313t-win_amd64.lib +0 -0
  17. numpy/_core/_umath_tests.cp313t-win_amd64.pyd +0 -0
  18. numpy/_core/lib/npymath.lib +0 -0
  19. numpy/_core/lib/pkgconfig/numpy.pc +1 -1
  20. numpy/_core/tests/test_datetime.py +24 -0
  21. numpy/_core/tests/test_stringdtype.py +7 -0
  22. numpy/_typing/_callable.pyi +4 -91
  23. numpy/fft/_pocketfft_umath.cp313t-win_amd64.lib +0 -0
  24. numpy/fft/_pocketfft_umath.cp313t-win_amd64.pyd +0 -0
  25. numpy/lib/_arraysetops_impl.pyi +24 -0
  26. numpy/linalg/_linalg.py +1 -0
  27. numpy/linalg/_umath_linalg.cp313t-win_amd64.lib +0 -0
  28. numpy/linalg/_umath_linalg.cp313t-win_amd64.pyd +0 -0
  29. numpy/linalg/lapack_lite.cp313t-win_amd64.lib +0 -0
  30. numpy/linalg/lapack_lite.cp313t-win_amd64.pyd +0 -0
  31. numpy/linalg/tests/test_linalg.py +14 -1
  32. numpy/random/_bounded_integers.cp313t-win_amd64.lib +0 -0
  33. numpy/random/_bounded_integers.cp313t-win_amd64.pyd +0 -0
  34. numpy/random/_common.cp313t-win_amd64.lib +0 -0
  35. numpy/random/_common.cp313t-win_amd64.pyd +0 -0
  36. numpy/random/_generator.cp313t-win_amd64.lib +0 -0
  37. numpy/random/_generator.cp313t-win_amd64.pyd +0 -0
  38. numpy/random/_mt19937.cp313t-win_amd64.lib +0 -0
  39. numpy/random/_mt19937.cp313t-win_amd64.pyd +0 -0
  40. numpy/random/_pcg64.cp313t-win_amd64.lib +0 -0
  41. numpy/random/_pcg64.cp313t-win_amd64.pyd +0 -0
  42. numpy/random/_philox.cp313t-win_amd64.lib +0 -0
  43. numpy/random/_philox.cp313t-win_amd64.pyd +0 -0
  44. numpy/random/_sfc64.cp313t-win_amd64.lib +0 -0
  45. numpy/random/_sfc64.cp313t-win_amd64.pyd +0 -0
  46. numpy/random/bit_generator.cp313t-win_amd64.lib +0 -0
  47. numpy/random/bit_generator.cp313t-win_amd64.pyd +0 -0
  48. numpy/random/lib/npyrandom.lib +0 -0
  49. numpy/random/mtrand.cp313t-win_amd64.lib +0 -0
  50. numpy/random/mtrand.cp313t-win_amd64.pyd +0 -0
  51. numpy/tests/test_configtool.py +1 -1
  52. numpy/typing/tests/data/fail/arithmetic.pyi +1 -1
  53. numpy/typing/tests/data/fail/bitwise_ops.pyi +1 -1
  54. numpy/version.py +2 -2
  55. numpy-2.3.3.dist-info/DELVEWHEEL +2 -0
  56. {numpy-2.3.2.dist-info → numpy-2.3.3.dist-info}/LICENSE.txt +881 -881
  57. {numpy-2.3.2.dist-info → numpy-2.3.3.dist-info}/METADATA +1 -1
  58. {numpy-2.3.2.dist-info → numpy-2.3.3.dist-info}/RECORD +60 -60
  59. numpy-2.3.2.dist-info/DELVEWHEEL +0 -2
  60. {numpy-2.3.2.dist-info → numpy-2.3.3.dist-info}/WHEEL +0 -0
  61. {numpy-2.3.2.dist-info → numpy-2.3.3.dist-info}/entry_points.txt +0 -0
numpy/__config__.py CHANGED
@@ -33,7 +33,7 @@ CONFIG = _cleanup(
33
33
  "c": {
34
34
  "name": "msvc",
35
35
  "linker": r"link",
36
- "version": "19.44.35213",
36
+ "version": "19.44.35215",
37
37
  "commands": r"cl",
38
38
  "args": r"",
39
39
  "linker args": r"",
@@ -41,7 +41,7 @@ CONFIG = _cleanup(
41
41
  "cython": {
42
42
  "name": "cython",
43
43
  "linker": r"cython",
44
- "version": "3.1.2",
44
+ "version": "3.1.3",
45
45
  "commands": r"cython",
46
46
  "args": r"",
47
47
  "linker args": r"",
@@ -49,7 +49,7 @@ CONFIG = _cleanup(
49
49
  "c++": {
50
50
  "name": "msvc",
51
51
  "linker": r"link",
52
- "version": "19.44.35213",
52
+ "version": "19.44.35215",
53
53
  "commands": r"cl",
54
54
  "args": r"",
55
55
  "linker args": r"",
@@ -76,24 +76,24 @@ CONFIG = _cleanup(
76
76
  "found": bool("True".lower().replace("false", "")),
77
77
  "version": "0.3.30",
78
78
  "detection method": "pkgconfig",
79
- "include directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-6rqsozuw/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/include",
80
- "lib directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-6rqsozuw/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/lib",
79
+ "include directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-92c8lxcz/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/include",
80
+ "lib directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-92c8lxcz/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/lib",
81
81
  "openblas configuration": r"OpenBLAS 0.3.30 USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=24",
82
- "pc file directory": r"D:/a/numpy/numpy/.openblas",
82
+ "pc file directory": r"D:/a/numpy-release/numpy-release/.openblas",
83
83
  },
84
84
  "lapack": {
85
85
  "name": "scipy-openblas",
86
86
  "found": bool("True".lower().replace("false", "")),
87
87
  "version": "0.3.30",
88
88
  "detection method": "pkgconfig",
89
- "include directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-6rqsozuw/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/include",
90
- "lib directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-6rqsozuw/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/lib",
89
+ "include directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-92c8lxcz/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/include",
90
+ "lib directory": r"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-92c8lxcz/cp313t-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/lib",
91
91
  "openblas configuration": r"OpenBLAS 0.3.30 USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=24",
92
- "pc file directory": r"D:/a/numpy/numpy/.openblas",
92
+ "pc file directory": r"D:/a/numpy-release/numpy-release/.openblas",
93
93
  },
94
94
  },
95
95
  "Python Information": {
96
- "path": r"C:\Users\runneradmin\AppData\Local\Temp\build-env-tg_qaa7d\Scripts\python.exe",
96
+ "path": r"C:\Users\runneradmin\AppData\Local\Temp\build-env-nztix4mr\Scripts\python.exe",
97
97
  "version": "3.13",
98
98
  },
99
99
  "SIMD Extensions": {
numpy/__init__.py CHANGED
@@ -88,14 +88,14 @@ Exceptions to this rule are documented.
88
88
 
89
89
 
90
90
  # start delvewheel patch
91
- def _delvewheel_patch_1_11_0():
91
+ def _delvewheel_patch_1_11_1():
92
92
  import os
93
93
  if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'numpy.libs'))):
94
94
  os.add_dll_directory(libs_dir)
95
95
 
96
96
 
97
- _delvewheel_patch_1_11_0()
98
- del _delvewheel_patch_1_11_0
97
+ _delvewheel_patch_1_11_1()
98
+ del _delvewheel_patch_1_11_1
99
99
  # end delvewheel patch
100
100
 
101
101
  import os
@@ -938,4 +938,4 @@ else:
938
938
 
939
939
 
940
940
  # Remove symbols imported for internal use
941
- del os, sys, warnings
941
+ del os, sys, warnings
numpy/__init__.pyi CHANGED
@@ -134,12 +134,6 @@ from numpy._typing import (
134
134
  )
135
135
 
136
136
  from numpy._typing._callable import (
137
- _BoolOp,
138
- _BoolBitOp,
139
- _BoolSub,
140
- _BoolTrueDiv,
141
- _BoolMod,
142
- _BoolDivMod,
143
137
  _IntTrueDiv,
144
138
  _UnsignedIntOp,
145
139
  _UnsignedIntBitOp,
@@ -803,6 +797,7 @@ _1NShapeT = TypeVar("_1NShapeT", bound=tuple[L[1], *tuple[L[1], ...]]) # (1,) |
803
797
  _ScalarT = TypeVar("_ScalarT", bound=generic)
804
798
  _ScalarT_co = TypeVar("_ScalarT_co", bound=generic, default=Any, covariant=True)
805
799
  _NumberT = TypeVar("_NumberT", bound=number)
800
+ _InexactT = TypeVar("_InexactT", bound=inexact)
806
801
  _RealNumberT = TypeVar("_RealNumberT", bound=floating | integer)
807
802
  _FloatingT_co = TypeVar("_FloatingT_co", bound=floating, default=floating, covariant=True)
808
803
  _IntegerT = TypeVar("_IntegerT", bound=integer)
@@ -2151,7 +2146,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
2151
2146
  @strides.setter
2152
2147
  def strides(self, value: _ShapeLike) -> None: ...
2153
2148
  def byteswap(self, inplace: builtins.bool = ...) -> Self: ...
2154
- def fill(self, value: Any) -> None: ...
2149
+ def fill(self, value: Any, /) -> None: ...
2155
2150
  @property
2156
2151
  def flat(self) -> flatiter[Self]: ...
2157
2152
 
@@ -3824,12 +3819,14 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
3824
3819
  def __init__(self: np.bool[builtins.bool], value: object, /) -> None: ...
3825
3820
 
3826
3821
  def __bool__(self, /) -> _BoolItemT_co: ...
3822
+
3827
3823
  @overload
3828
3824
  def __int__(self: np.bool[L[False]], /) -> L[0]: ...
3829
3825
  @overload
3830
3826
  def __int__(self: np.bool[L[True]], /) -> L[1]: ...
3831
3827
  @overload
3832
3828
  def __int__(self, /) -> L[0, 1]: ...
3829
+
3833
3830
  def __abs__(self) -> Self: ...
3834
3831
 
3835
3832
  @overload
@@ -3839,23 +3836,191 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
3839
3836
  @overload
3840
3837
  def __invert__(self, /) -> np.bool: ...
3841
3838
 
3842
- __add__: _BoolOp[np.bool]
3843
- __radd__: _BoolOp[np.bool]
3844
- __sub__: _BoolSub
3845
- __rsub__: _BoolSub
3846
- __mul__: _BoolOp[np.bool]
3847
- __rmul__: _BoolOp[np.bool]
3848
- __truediv__: _BoolTrueDiv
3849
- __rtruediv__: _BoolTrueDiv
3850
- __floordiv__: _BoolOp[int8]
3851
- __rfloordiv__: _BoolOp[int8]
3852
- __pow__: _BoolOp[int8]
3853
- __rpow__: _BoolOp[int8]
3854
-
3855
- __lshift__: _BoolBitOp[int8]
3856
- __rlshift__: _BoolBitOp[int8]
3857
- __rshift__: _BoolBitOp[int8]
3858
- __rrshift__: _BoolBitOp[int8]
3839
+ @overload
3840
+ def __add__(self, other: _NumberT, /) -> _NumberT: ...
3841
+ @overload
3842
+ def __add__(self, other: builtins.bool | bool_, /) -> bool_: ...
3843
+ @overload
3844
+ def __add__(self, other: int, /) -> int_: ...
3845
+ @overload
3846
+ def __add__(self, other: float, /) -> float64: ...
3847
+ @overload
3848
+ def __add__(self, other: complex, /) -> complex128: ...
3849
+
3850
+ @overload
3851
+ def __radd__(self, other: _NumberT, /) -> _NumberT: ...
3852
+ @overload
3853
+ def __radd__(self, other: builtins.bool, /) -> bool_: ...
3854
+ @overload
3855
+ def __radd__(self, other: int, /) -> int_: ...
3856
+ @overload
3857
+ def __radd__(self, other: float, /) -> float64: ...
3858
+ @overload
3859
+ def __radd__(self, other: complex, /) -> complex128: ...
3860
+
3861
+ @overload
3862
+ def __sub__(self, other: _NumberT, /) -> _NumberT: ...
3863
+ @overload
3864
+ def __sub__(self, other: int, /) -> int_: ...
3865
+ @overload
3866
+ def __sub__(self, other: float, /) -> float64: ...
3867
+ @overload
3868
+ def __sub__(self, other: complex, /) -> complex128: ...
3869
+
3870
+ @overload
3871
+ def __rsub__(self, other: _NumberT, /) -> _NumberT: ...
3872
+ @overload
3873
+ def __rsub__(self, other: int, /) -> int_: ...
3874
+ @overload
3875
+ def __rsub__(self, other: float, /) -> float64: ...
3876
+ @overload
3877
+ def __rsub__(self, other: complex, /) -> complex128: ...
3878
+
3879
+ @overload
3880
+ def __mul__(self, other: _NumberT, /) -> _NumberT: ...
3881
+ @overload
3882
+ def __mul__(self, other: builtins.bool | bool_, /) -> bool_: ...
3883
+ @overload
3884
+ def __mul__(self, other: int, /) -> int_: ...
3885
+ @overload
3886
+ def __mul__(self, other: float, /) -> float64: ...
3887
+ @overload
3888
+ def __mul__(self, other: complex, /) -> complex128: ...
3889
+
3890
+ @overload
3891
+ def __rmul__(self, other: _NumberT, /) -> _NumberT: ...
3892
+ @overload
3893
+ def __rmul__(self, other: builtins.bool, /) -> bool_: ...
3894
+ @overload
3895
+ def __rmul__(self, other: int, /) -> int_: ...
3896
+ @overload
3897
+ def __rmul__(self, other: float, /) -> float64: ...
3898
+ @overload
3899
+ def __rmul__(self, other: complex, /) -> complex128: ...
3900
+
3901
+ @overload
3902
+ def __pow__(self, other: _NumberT, mod: None = None, /) -> _NumberT: ...
3903
+ @overload
3904
+ def __pow__(self, other: builtins.bool | bool_, mod: None = None, /) -> int8: ...
3905
+ @overload
3906
+ def __pow__(self, other: int, mod: None = None, /) -> int_: ...
3907
+ @overload
3908
+ def __pow__(self, other: float, mod: None = None, /) -> float64: ...
3909
+ @overload
3910
+ def __pow__(self, other: complex, mod: None = None, /) -> complex128: ...
3911
+
3912
+ @overload
3913
+ def __rpow__(self, other: _NumberT, mod: None = None, /) -> _NumberT: ...
3914
+ @overload
3915
+ def __rpow__(self, other: builtins.bool, mod: None = None, /) -> int8: ...
3916
+ @overload
3917
+ def __rpow__(self, other: int, mod: None = None, /) -> int_: ...
3918
+ @overload
3919
+ def __rpow__(self, other: float, mod: None = None, /) -> float64: ...
3920
+ @overload
3921
+ def __rpow__(self, other: complex, mod: None = None, /) -> complex128: ...
3922
+
3923
+ @overload
3924
+ def __truediv__(self, other: _InexactT, /) -> _InexactT: ...
3925
+ @overload
3926
+ def __truediv__(self, other: float | integer | bool_, /) -> float64: ...
3927
+ @overload
3928
+ def __truediv__(self, other: complex, /) -> complex128: ...
3929
+
3930
+ @overload
3931
+ def __rtruediv__(self, other: _InexactT, /) -> _InexactT: ...
3932
+ @overload
3933
+ def __rtruediv__(self, other: float | integer, /) -> float64: ...
3934
+ @overload
3935
+ def __rtruediv__(self, other: complex, /) -> complex128: ...
3936
+
3937
+ @overload
3938
+ def __floordiv__(self, other: _RealNumberT, /) -> _RealNumberT: ...
3939
+ @overload
3940
+ def __floordiv__(self, other: builtins.bool | bool_, /) -> int8: ...
3941
+ @overload
3942
+ def __floordiv__(self, other: int, /) -> int_: ...
3943
+ @overload
3944
+ def __floordiv__(self, other: float, /) -> float64: ...
3945
+
3946
+ @overload
3947
+ def __rfloordiv__(self, other: _RealNumberT, /) -> _RealNumberT: ...
3948
+ @overload
3949
+ def __rfloordiv__(self, other: builtins.bool, /) -> int8: ...
3950
+ @overload
3951
+ def __rfloordiv__(self, other: int, /) -> int_: ...
3952
+ @overload
3953
+ def __rfloordiv__(self, other: float, /) -> float64: ...
3954
+
3955
+ # keep in sync with __floordiv__
3956
+ @overload
3957
+ def __mod__(self, other: _RealNumberT, /) -> _RealNumberT: ...
3958
+ @overload
3959
+ def __mod__(self, other: builtins.bool | bool_, /) -> int8: ...
3960
+ @overload
3961
+ def __mod__(self, other: int, /) -> int_: ...
3962
+ @overload
3963
+ def __mod__(self, other: float, /) -> float64: ...
3964
+
3965
+ # keep in sync with __rfloordiv__
3966
+ @overload
3967
+ def __rmod__(self, other: _RealNumberT, /) -> _RealNumberT: ...
3968
+ @overload
3969
+ def __rmod__(self, other: builtins.bool, /) -> int8: ...
3970
+ @overload
3971
+ def __rmod__(self, other: int, /) -> int_: ...
3972
+ @overload
3973
+ def __rmod__(self, other: float, /) -> float64: ...
3974
+
3975
+ # keep in sync with __mod__
3976
+ @overload
3977
+ def __divmod__(self, other: _RealNumberT, /) -> _2Tuple[_RealNumberT]: ...
3978
+ @overload
3979
+ def __divmod__(self, other: builtins.bool | bool_, /) -> _2Tuple[int8]: ...
3980
+ @overload
3981
+ def __divmod__(self, other: int, /) -> _2Tuple[int_]: ...
3982
+ @overload
3983
+ def __divmod__(self, other: float, /) -> _2Tuple[float64]: ...
3984
+
3985
+ # keep in sync with __rmod__
3986
+ @overload
3987
+ def __rdivmod__(self, other: _RealNumberT, /) -> _2Tuple[_RealNumberT]: ...
3988
+ @overload
3989
+ def __rdivmod__(self, other: builtins.bool, /) -> _2Tuple[int8]: ...
3990
+ @overload
3991
+ def __rdivmod__(self, other: int, /) -> _2Tuple[int_]: ...
3992
+ @overload
3993
+ def __rdivmod__(self, other: float, /) -> _2Tuple[float64]: ...
3994
+
3995
+ @overload
3996
+ def __lshift__(self, other: _IntegerT, /) -> _IntegerT: ...
3997
+ @overload
3998
+ def __lshift__(self, other: builtins.bool | bool_, /) -> int8: ...
3999
+ @overload
4000
+ def __lshift__(self, other: int, /) -> int_: ...
4001
+
4002
+ @overload
4003
+ def __rlshift__(self, other: _IntegerT, /) -> _IntegerT: ...
4004
+ @overload
4005
+ def __rlshift__(self, other: builtins.bool, /) -> int8: ...
4006
+ @overload
4007
+ def __rlshift__(self, other: int, /) -> int_: ...
4008
+
4009
+ # keep in sync with __lshift__
4010
+ @overload
4011
+ def __rshift__(self, other: _IntegerT, /) -> _IntegerT: ...
4012
+ @overload
4013
+ def __rshift__(self, other: builtins.bool | bool_, /) -> int8: ...
4014
+ @overload
4015
+ def __rshift__(self, other: int, /) -> int_: ...
4016
+
4017
+ # keep in sync with __rlshift__
4018
+ @overload
4019
+ def __rrshift__(self, other: _IntegerT, /) -> _IntegerT: ...
4020
+ @overload
4021
+ def __rrshift__(self, other: builtins.bool, /) -> int8: ...
4022
+ @overload
4023
+ def __rrshift__(self, other: int, /) -> int_: ...
3859
4024
 
3860
4025
  @overload
3861
4026
  def __and__(self: np.bool[L[False]], other: builtins.bool | np.bool, /) -> np.bool[L[False]]: ...
@@ -3899,11 +4064,6 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
3899
4064
  def __or__(self, other: int, /) -> np.bool | intp: ...
3900
4065
  __ror__ = __or__
3901
4066
 
3902
- __mod__: _BoolMod
3903
- __rmod__: _BoolMod
3904
- __divmod__: _BoolDivMod
3905
- __rdivmod__: _BoolDivMod
3906
-
3907
4067
  __lt__: _ComparisonOpLT[_NumberLike_co, _ArrayLikeNumber_co]
3908
4068
  __le__: _ComparisonOpLE[_NumberLike_co, _ArrayLikeNumber_co]
3909
4069
  __gt__: _ComparisonOpGT[_NumberLike_co, _ArrayLikeNumber_co]
Binary file
Binary file
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.2
6
+ Version: 2.3.3
7
7
  Cflags: -I${includedir}
@@ -844,6 +844,21 @@ class TestDateTime:
844
844
  a = np.array([-1, 'NaT', 1234567], dtype='<m')
845
845
  assert_equal(str(a), "[ -1 'NaT' 1234567]")
846
846
 
847
+ def test_timedelta_array_with_nats(self):
848
+ # Regression test for gh-29497.
849
+ x = np.array([np.timedelta64('nat'),
850
+ np.timedelta64('nat', 's'),
851
+ np.timedelta64('nat', 'ms'),
852
+ np.timedelta64(123, 'ms')])
853
+ for td in x[:3]:
854
+ assert np.isnat(td)
855
+
856
+ def test_timedelta_array_nat_assignment(self):
857
+ # Regression test for gh-29497.
858
+ x = np.zeros(3, dtype='m8[ms]')
859
+ x[1] = np.timedelta64('nat', 's')
860
+ assert np.isnat(x[1])
861
+
847
862
  def test_pickle(self):
848
863
  # Check that pickle roundtripping works
849
864
  for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
@@ -872,6 +887,15 @@ class TestDateTime:
872
887
  b"I1\nI1\nI1\ntp7\ntp8\ntp9\nb."
873
888
  assert_equal(pickle.loads(pkl), np.dtype('>M8[us]'))
874
889
 
890
+ def test_gh_29555(self):
891
+ # check that dtype metadata round-trips when none
892
+ dt = np.dtype('>M8[us]')
893
+ assert dt.metadata is None
894
+ for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
895
+ res = pickle.loads(pickle.dumps(dt, protocol=proto))
896
+ assert_equal(res, dt)
897
+ assert res.metadata is None
898
+
875
899
  def test_setstate(self):
876
900
  "Verify that datetime dtype __setstate__ can handle bad arguments"
877
901
  dt = np.dtype('>M8[us]')
@@ -531,6 +531,13 @@ def test_fancy_indexing(string_list):
531
531
  assert_array_equal(sarr[ind], uarr[ind])
532
532
 
533
533
 
534
+ def test_flatiter_indexing():
535
+ # see gh-29659
536
+ arr = np.array(['hello', 'world'], dtype='T')
537
+ arr.flat[:] = 9223372036854775
538
+ assert_array_equal(arr, np.array([9223372036854775] * 2, dtype='T'))
539
+
540
+
534
541
  def test_creation_functions():
535
542
  assert_array_equal(np.zeros(3, dtype="T"), ["", "", ""])
536
543
  assert_array_equal(np.empty(3, dtype="T"), ["", "", ""])
@@ -8,16 +8,7 @@ See the `Mypy documentation`_ on protocols for more details.
8
8
 
9
9
  """
10
10
 
11
- from typing import (
12
- Any,
13
- NoReturn,
14
- Protocol,
15
- TypeAlias,
16
- TypeVar,
17
- final,
18
- overload,
19
- type_check_only,
20
- )
11
+ from typing import Any, Protocol, TypeAlias, TypeVar, final, overload, type_check_only
21
12
 
22
13
  import numpy as np
23
14
  from numpy import (
@@ -26,7 +17,6 @@ from numpy import (
26
17
  float64,
27
18
  floating,
28
19
  generic,
29
- int8,
30
20
  int_,
31
21
  integer,
32
22
  number,
@@ -38,18 +28,13 @@ from . import NBitBase
38
28
  from ._array_like import NDArray
39
29
  from ._nbit import _NBitInt
40
30
  from ._nested_sequence import _NestedSequence
41
- from ._scalars import (
42
- _BoolLike_co,
43
- _IntLike_co,
44
- _NumberLike_co,
45
- )
31
+ from ._scalars import _NumberLike_co
46
32
 
47
- _T1 = TypeVar("_T1")
48
- _T2 = TypeVar("_T2")
33
+ _T = TypeVar("_T")
49
34
  _T1_contra = TypeVar("_T1_contra", contravariant=True)
50
35
  _T2_contra = TypeVar("_T2_contra", contravariant=True)
51
36
 
52
- _2Tuple: TypeAlias = tuple[_T1, _T1]
37
+ _2Tuple: TypeAlias = tuple[_T, _T]
53
38
 
54
39
  _NBit1 = TypeVar("_NBit1", bound=NBitBase)
55
40
  _NBit2 = TypeVar("_NBit2", bound=NBitBase)
@@ -57,80 +42,8 @@ _NBit2 = TypeVar("_NBit2", bound=NBitBase)
57
42
  _IntType = TypeVar("_IntType", bound=integer)
58
43
  _FloatType = TypeVar("_FloatType", bound=floating)
59
44
  _NumberType = TypeVar("_NumberType", bound=number)
60
- _NumberType_co = TypeVar("_NumberType_co", covariant=True, bound=number)
61
45
  _GenericType_co = TypeVar("_GenericType_co", covariant=True, bound=generic)
62
46
 
63
- @type_check_only
64
- class _BoolOp(Protocol[_GenericType_co]):
65
- @overload
66
- def __call__(self, other: _BoolLike_co, /) -> _GenericType_co: ...
67
- @overload # platform dependent
68
- def __call__(self, other: int, /) -> int_: ...
69
- @overload
70
- def __call__(self, other: float, /) -> float64: ...
71
- @overload
72
- def __call__(self, other: complex, /) -> complex128: ...
73
- @overload
74
- def __call__(self, other: _NumberType, /) -> _NumberType: ...
75
-
76
- @type_check_only
77
- class _BoolBitOp(Protocol[_GenericType_co]):
78
- @overload
79
- def __call__(self, other: _BoolLike_co, /) -> _GenericType_co: ...
80
- @overload # platform dependent
81
- def __call__(self, other: int, /) -> int_: ...
82
- @overload
83
- def __call__(self, other: _IntType, /) -> _IntType: ...
84
-
85
- @type_check_only
86
- class _BoolSub(Protocol):
87
- # Note that `other: bool` is absent here
88
- @overload
89
- def __call__(self, other: bool, /) -> NoReturn: ...
90
- @overload # platform dependent
91
- def __call__(self, other: int, /) -> int_: ...
92
- @overload
93
- def __call__(self, other: float, /) -> float64: ...
94
- @overload
95
- def __call__(self, other: complex, /) -> complex128: ...
96
- @overload
97
- def __call__(self, other: _NumberType, /) -> _NumberType: ...
98
-
99
- @type_check_only
100
- class _BoolTrueDiv(Protocol):
101
- @overload
102
- def __call__(self, other: float | _IntLike_co, /) -> float64: ...
103
- @overload
104
- def __call__(self, other: complex, /) -> complex128: ...
105
- @overload
106
- def __call__(self, other: _NumberType, /) -> _NumberType: ...
107
-
108
- @type_check_only
109
- class _BoolMod(Protocol):
110
- @overload
111
- def __call__(self, other: _BoolLike_co, /) -> int8: ...
112
- @overload # platform dependent
113
- def __call__(self, other: int, /) -> int_: ...
114
- @overload
115
- def __call__(self, other: float, /) -> float64: ...
116
- @overload
117
- def __call__(self, other: _IntType, /) -> _IntType: ...
118
- @overload
119
- def __call__(self, other: _FloatType, /) -> _FloatType: ...
120
-
121
- @type_check_only
122
- class _BoolDivMod(Protocol):
123
- @overload
124
- def __call__(self, other: _BoolLike_co, /) -> _2Tuple[int8]: ...
125
- @overload # platform dependent
126
- def __call__(self, other: int, /) -> _2Tuple[int_]: ...
127
- @overload
128
- def __call__(self, other: float, /) -> _2Tuple[np.float64]: ...
129
- @overload
130
- def __call__(self, other: _IntType, /) -> _2Tuple[_IntType]: ...
131
- @overload
132
- def __call__(self, other: _FloatType, /) -> _2Tuple[_FloatType]: ...
133
-
134
47
  @type_check_only
135
48
  class _IntTrueDiv(Protocol[_NBit1]):
136
49
  @overload