@@ -205,13 +205,13 @@ from numpy import (
205205 matrixlib as matrixlib ,
206206 polynomial as polynomial ,
207207 random as random ,
208- rec as rec ,
209208 testing as testing ,
210209 version as version ,
211210)
212211
213- from numpy .core import defchararray
212+ from numpy .core import defchararray , records
214213char = defchararray
214+ rec = records
215215
216216from numpy .core .function_base import (
217217 linspace as linspace ,
@@ -706,16 +706,6 @@ class chararray(ndarray[_ShapeType, _DType_co]):
706706 def isnumeric (self ): ...
707707 def isdecimal (self ): ...
708708
709- class format_parser :
710- def __init__ (
711- self ,
712- formats : Any ,
713- names : Any ,
714- titles : Any ,
715- aligned : Any = ...,
716- byteorder : Any = ...,
717- ) -> None : ...
718-
719709class matrix (ndarray [_ShapeType , _DType_co ]):
720710 def __new__ (
721711 subtype ,
@@ -804,7 +794,6 @@ class nditer:
804794 def __setitem__ (self , index : SupportsIndex | slice , value : Any ) -> None : ...
805795 def __delitem__ (self , key : SupportsIndex | slice ) -> None : ...
806796
807-
808797class poly1d :
809798 def __init__ (
810799 self ,
@@ -863,33 +852,6 @@ class poly1d:
863852 def integ (self , m = ..., k = ...): ...
864853 def deriv (self , m = ...): ...
865854
866- class recarray (ndarray [_ShapeType , _DType_co ]):
867- def __new__ (
868- subtype ,
869- shape : Any ,
870- dtype : Any = ...,
871- buf : Any = ...,
872- offset : Any = ...,
873- strides : Any = ...,
874- formats : Any = ...,
875- names : Any = ...,
876- titles : Any = ...,
877- byteorder : Any = ...,
878- aligned : Any = ...,
879- order : Any = ...,
880- ) -> Any : ...
881- def __array_finalize__ (self , obj ): ...
882- def __getattribute__ (self , attr ): ...
883- def __setattr__ (self , attr , val ): ...
884- def __getitem__ (self , indx ): ...
885- def field (self , attr , val = ...): ...
886-
887- class record (void ):
888- def __getattribute__ (self , attr ): ...
889- def __setattr__ (self , attr , val ): ...
890- def __getitem__ (self , indx ): ...
891- def pprint (self ): ...
892-
893855class vectorize :
894856 pyfunc : Any
895857 cache : Any
@@ -1694,9 +1656,9 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
16941656 cls : Type [_ArraySelf ],
16951657 shape : _ShapeLike ,
16961658 dtype : DTypeLike = ...,
1697- buffer : _SupportsBuffer = ...,
1698- offset : int = ...,
1699- strides : _ShapeLike = ...,
1659+ buffer : None | _SupportsBuffer = ...,
1660+ offset : SupportsIndex = ...,
1661+ strides : None | _ShapeLike = ...,
17001662 order : _OrderKACF = ...,
17011663 ) -> _ArraySelf : ...
17021664 @overload
@@ -3292,8 +3254,15 @@ class void(flexible):
32923254 def setfield (
32933255 self , val : ArrayLike , dtype : DTypeLike , offset : int = ...
32943256 ) -> None : ...
3295- def __getitem__ (self , key : SupportsIndex ) -> Any : ...
3296- def __setitem__ (self , key : SupportsIndex , value : ArrayLike ) -> None : ...
3257+ @overload
3258+ def __getitem__ (self , key : str | SupportsIndex ) -> Any : ...
3259+ @overload
3260+ def __getitem__ (self , key : list [str ]) -> void : ...
3261+ def __setitem__ (
3262+ self ,
3263+ key : str | List [str ] | SupportsIndex ,
3264+ value : ArrayLike ,
3265+ ) -> None : ...
32973266
32983267void0 = void
32993268
@@ -3704,3 +3673,69 @@ class iinfo(Generic[_IntType]):
37043673 def __new__ (cls , dtype : int | Type [int ]) -> iinfo [int_ ]: ...
37053674 @overload
37063675 def __new__ (cls , dtype : str ) -> iinfo [Any ]: ...
3676+
3677+ class format_parser :
3678+ dtype : dtype [void ]
3679+ def __init__ (
3680+ self ,
3681+ formats : DTypeLike ,
3682+ names : None | str | Sequence [str ],
3683+ titles : None | str | Sequence [str ],
3684+ aligned : bool = ...,
3685+ byteorder : None | _ByteOrder = ...,
3686+ ) -> None : ...
3687+
3688+ # TODO: field-lookup returns either a `recarray` or a `ndarray`
3689+ # depending on the field dtype
3690+ class recarray (ndarray [_ShapeType , _DType_co ]):
3691+ # NOTE: While not strictly mandatory, we're demanding here that arguments
3692+ # for the `format_parser`- and `dtype`-based dtype constructors are
3693+ # mutually exclusive
3694+ @overload
3695+ def __new__ (
3696+ subtype ,
3697+ shape : _ShapeLike ,
3698+ dtype : None = ...,
3699+ buf : None | _SupportsBuffer = ...,
3700+ offset : SupportsIndex = ...,
3701+ strides : None | _ShapeLike = ...,
3702+ * ,
3703+ formats : DTypeLike ,
3704+ names : None | str | Sequence [str ] = ...,
3705+ titles : None | str | Sequence [str ] = ...,
3706+ byteorder : None | _ByteOrder = ...,
3707+ aligned : bool = ...,
3708+ order : _OrderKACF = ...,
3709+ ) -> recarray [Any , dtype [record ]]: ...
3710+ @overload
3711+ def __new__ (
3712+ subtype ,
3713+ shape : _ShapeLike ,
3714+ dtype : DTypeLike ,
3715+ buf : None | _SupportsBuffer = ...,
3716+ offset : SupportsIndex = ...,
3717+ strides : None | _ShapeLike = ...,
3718+ formats : None = ...,
3719+ names : None = ...,
3720+ titles : None = ...,
3721+ byteorder : None = ...,
3722+ aligned : L [False ] = ...,
3723+ order : _OrderKACF = ...,
3724+ ) -> recarray [Any , dtype [Any ]]: ...
3725+ def __array_finalize__ (self , obj : object ) -> None : ...
3726+ def __getattribute__ (self , attr : str ) -> Any : ...
3727+ def __setattr__ (self , attr : str , val : ArrayLike ) -> None : ...
3728+ def __getitem__ (self , indx ): ... # TODO
3729+ @overload
3730+ def field (self , attr : int | str , val : None = ...) -> Any : ...
3731+ @overload
3732+ def field (self , attr : int | str , val : ArrayLike ) -> None : ...
3733+
3734+ class record (void ):
3735+ def __getattribute__ (self , attr : str ) -> Any : ...
3736+ def __setattr__ (self , attr : str , val : ArrayLike ) -> None : ...
3737+ def pprint (self ) -> str : ...
3738+ @overload
3739+ def __getitem__ (self , key : str | SupportsIndex ) -> Any : ...
3740+ @overload
3741+ def __getitem__ (self , key : list [str ]) -> record : ...
0 commit comments