Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/_numtype/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,159 +2,160 @@
# future.

# NOTE: The `TypeAliasType` backport is used to avoid long type-checker error messages.
import decimal
import fractions
from collections.abc import Sequence
from typing import Any, TypeAlias, type_check_only
from typing_extensions import Protocol, TypeAliasType, TypeVar

import numpy as np
from numpy._typing import _NestedSequence # noqa: PLC2701

from . import op as op
from ._array import (
Array as Array,
Array0D as Array0D,
Array1D as Array1D,
Array2D as Array2D,
Array3D as Array3D,
Array4D as Array4D,
MArray as MArray,
MArray0D as MArray0D,
MArray1D as MArray1D,
MArray2D as MArray2D,
MArray3D as MArray3D,
Matrix as Matrix,
StringArray as StringArray,
StringArray0D as StringArray0D,
StringArray1D as StringArray1D,
StringArray2D as StringArray2D,
StringArray3D as StringArray3D,
StringArrayND as StringArrayND,
)
from ._dtype import (
ToDType as ToDType,
ToDTypeBool as ToDTypeBool,
ToDTypeBytes as ToDTypeBytes,
ToDTypeCLongDouble as ToDTypeCLongDouble,
ToDTypeComplex64 as ToDTypeComplex64,
ToDTypeComplex128 as ToDTypeComplex128,
ToDTypeDateTime64 as ToDTypeDateTime64,
ToDTypeFloat16 as ToDTypeFloat16,
ToDTypeFloat32 as ToDTypeFloat32,
ToDTypeFloat64 as ToDTypeFloat64,
ToDTypeInt8 as ToDTypeInt8,
ToDTypeInt16 as ToDTypeInt16,
ToDTypeInt32 as ToDTypeInt32,
ToDTypeInt64 as ToDTypeInt64,
ToDTypeLong as ToDTypeLong,
ToDTypeLongDouble as ToDTypeLongDouble,
ToDTypeObject as ToDTypeObject,
ToDTypeStr as ToDTypeStr,
ToDTypeString as ToDTypeString,
ToDTypeTimeDelta64 as ToDTypeTimeDelta64,
ToDTypeUInt8 as ToDTypeUInt8,
ToDTypeUInt16 as ToDTypeUInt16,
ToDTypeUInt32 as ToDTypeUInt32,
ToDTypeUInt64 as ToDTypeUInt64,
ToDTypeULong as ToDTypeULong,
ToDTypeVoid as ToDTypeVoid,
_ToDType as _ToDType,
)
from ._just import (
Just as Just,
JustBytes as JustBytes,
JustComplex as JustComplex,
JustDate as JustDate,
JustFloat as JustFloat,
JustInt as JustInt,
JustObject as JustObject,
JustStr as JustStr,
)
from ._nep50 import (
Casts as Casts,
CastsArray as CastsArray,
CastsScalar as CastsScalar,
CastsWith as CastsWith,
CastsWithArray as CastsWithArray,
CastsWithBuiltin as CastsWithBuiltin,
CastsWithComplex as CastsWithComplex,
CastsWithFloat as CastsWithFloat,
CastsWithInt as CastsWithInt,
CastsWithScalar as CastsWithScalar,
)
from ._rank import (
AnyRank as AnyRank,
HasInnerShape as HasInnerShape,
HasRankGE as HasRankGE,
HasRankLE as HasRankLE,
Rank as Rank,
Rank0 as Rank0,
Rank0N as Rank0N,
Rank1 as Rank1,
Rank1N as Rank1N,
Rank2 as Rank2,
Rank2N as Rank2N,
Rank3 as Rank3,
Rank3N as Rank3N,
Rank4 as Rank4,
Rank4N as Rank4N,
)
from ._scalar import (
inexact32 as inexact32,
inexact64 as inexact64,
inexact64l as inexact64l,
integer8 as integer8,
integer16 as integer16,
integer32 as integer32,
integer64 as integer64,
integer_l as integer_l,
number16 as number16,
number32 as number32,
number64 as number64,
)
from ._scalar_co import (
co_complex as co_complex,
co_complex64 as co_complex64,
co_complex128 as co_complex128,
co_datetime as co_datetime,
co_float as co_float,
co_float16 as co_float16,
co_float32 as co_float32,
co_float64 as co_float64,
co_int8 as co_int8,
co_int16 as co_int16,
co_int32 as co_int32,
co_int64 as co_int64,
co_integer as co_integer,
co_integer8 as co_integer8,
co_integer16 as co_integer16,
co_integer32 as co_integer32,
co_integer64 as co_integer64,
co_long as co_long,
co_number as co_number,
co_timedelta as co_timedelta,
co_uint8 as co_uint8,
co_uint16 as co_uint16,
co_uint32 as co_uint32,
co_uint64 as co_uint64,
co_ulong as co_ulong,
)
from ._shape import (
AnyShape as AnyShape,
NeitherShape as NeitherShape,
Shape as Shape,
_ShapeLike as _ShapeLike,
Shape0 as Shape0,
Shape0N as Shape0N,
Shape1 as Shape1,
Shape1N as Shape1N,
Shape2 as Shape2,
Shape2N as Shape2N,
Shape3 as Shape3,
Shape3N as Shape3N,
Shape4 as Shape4,
Shape4N as Shape4N,
)

Check failure on line 158 in src/_numtype/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (I001)

src/_numtype/__init__.pyi:5:1: I001 Import block is un-sorted or un-formatted help: Organize imports

###
# Type parameters
Expand Down
5 changes: 4 additions & 1 deletion src/_numtype/_shape.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Never, TypeAlias
from collections.abc import Sequence
from typing import Any, Never, SupportsIndex, TypeAlias
from typing_extensions import TypeAliasType

__all__ = [
Expand Down Expand Up @@ -35,3 +36,5 @@
Shape2N = TypeAliasType("Shape2N", tuple[int, int, *tuple[int, ...]])
Shape3N = TypeAliasType("Shape3N", tuple[int, int, int, *tuple[int, ...]])
Shape4N = TypeAliasType("Shape4N", tuple[int, int, int, int, *tuple[int, ...]])

_ShapeLike: TypeAlias = SupportsIndex | Sequence[SupportsIndex]

Check failure on line 40 in src/_numtype/_shape.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (PYI047)

src/_numtype/_shape.pyi:40:1: PYI047 Private TypeAlias `_ShapeLike` is never used
3 changes: 2 additions & 1 deletion src/numpy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -346,96 +346,97 @@
_NestedSequence,
_NumberLike_co,
_ScalarLike_co,
_ShapeLike,
_TD64Like_co,
)

_ShapeLike = _nt._ShapeLike
from .lib import scimath as emath

Check failure on line 353 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:353:1: E402 Module level import not at top of file
from .lib._arraypad_impl import pad

Check failure on line 354 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:354:1: E402 Module level import not at top of file
from .lib._arraysetops_impl import (
ediff1d,
intersect1d,
isin,
setdiff1d,
setxor1d,
union1d,
unique,
unique_all,
unique_counts,
unique_inverse,
unique_values,
)

Check failure on line 367 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:355:1: E402 Module level import not at top of file
from .lib._function_base_impl import (
angle,
append,
asarray_chkfinite,
average,
bartlett,
blackman,
copy,
corrcoef,
cov,
delete,
diff,
digitize,
extract,
flip,
gradient,
hamming,
hanning,
i0,
insert,
interp,
iterable,
kaiser,
median,
meshgrid,
percentile,
piecewise,
place,
quantile,
rot90,
select,
sinc,
sort_complex,
trapezoid,
trim_zeros,
unwrap,
vectorize,
)

Check failure on line 405 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:368:1: E402 Module level import not at top of file
from .lib._histograms_impl import histogram, histogram_bin_edges, histogramdd

Check failure on line 406 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:406:1: E402 Module level import not at top of file
from .lib._index_tricks_impl import (
c_,
diag_indices,
diag_indices_from,
fill_diagonal,
index_exp,
ix_,
mgrid,
ndenumerate,
ndindex,
ogrid,
r_,
ravel_multi_index,
s_,
unravel_index,
)

Check failure on line 422 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:407:1: E402 Module level import not at top of file
from .lib._nanfunctions_impl import (
nanargmax,
nanargmin,
nancumprod,
nancumsum,
nanmax,
nanmean,
nanmedian,
nanmin,
nanpercentile,
nanprod,
nanquantile,
nanstd,
nansum,
nanvar,
)

Check failure on line 438 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:423:1: E402 Module level import not at top of file
from .lib._npyio_impl import fromregex, genfromtxt, load, loadtxt, save, savetxt, savez, savez_compressed

Check failure on line 439 in src/numpy-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / lint

ruff (E402)

src/numpy-stubs/__init__.pyi:439:1: E402 Module level import not at top of file
from .lib._polynomial_impl import (
poly,
poly1d,
Expand Down
3 changes: 2 additions & 1 deletion src/numpy-stubs/_core/_multiarray_umath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ from numpy._typing import (
_ArrayLikeNumber_co,
_DTypeLike,
_ScalarLike_co,
_ShapeLike,
_SupportsArrayFunc as _CanArrayFunc,
_SupportsDType as _HasDType,
)

_ShapeLike = _nt._ShapeLike

# needed for stubtest
from .umath import (
clip as clip,
Expand Down
3 changes: 2 additions & 1 deletion src/numpy-stubs/_core/defchararray.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ from numpy import _OrderKACF as _Order # noqa: ICN003
from numpy._typing import (
_ArrayLikeAnyString_co as _ToAnyCharND,
_ArrayLikeString_co as _ToStringND,
_ShapeLike as _ToShape,
)

_ToShape: TypeAlias = _nt._ShapeLike

from ._multiarray_umath import compare_chararrays
from .strings import (
capitalize,
Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/_core/fromnumeric.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import _numtype as _nt
import numpy as np
from numpy import _CastingKind, _ModeKind, _OrderACF, _OrderKACF, _PartitionKind, _SortKind, _SortSide # noqa: ICN003
from numpy._globals import _NoValueType
from numpy._typing import ArrayLike, DTypeLike, _DTypeLike, _ShapeLike
from numpy._typing import ArrayLike, DTypeLike, _DTypeLike

_ShapeLike = _nt._ShapeLike

__all__ = [
"all",
Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/_core/memmap.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import _numtype as _nt
import numpy as np
import numpy.typing as npt
from numpy import _OrderKACF # noqa: ICN003
from numpy._typing import _DTypeLike, _ShapeLike
from numpy._typing import _DTypeLike

_ShapeLike = _nt._ShapeLike

__all__ = ["memmap"]

Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/_core/numeric.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import _numtype as _nt
import numpy as np
import numpy.typing as npt
from numpy import _AnyShapeT, _OrderCF, _OrderKACF, ufunc # noqa: ICN003
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike, _DTypeLike, _ShapeLike, _SupportsArrayFunc, _SupportsDType
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike, _DTypeLike, _SupportsArrayFunc, _SupportsDType
from numpy.lib._array_utils_impl import normalize_axis_tuple as normalize_axis_tuple

_ShapeLike = _nt._ShapeLike

from ._asarray import require
from ._ufunc_config import errstate, getbufsize, geterr, geterrcall, setbufsize, seterr, seterrcall
from .arrayprint import (
Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/_core/records.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ from typing_extensions import Buffer, TypeVar, override
import _numtype as _nt
import numpy as np
from numpy import _ByteOrder, _OrderKACF # noqa: ICN003
from numpy._typing import ArrayLike, DTypeLike, _ArrayLikeVoid_co, _ShapeLike
from numpy._typing import ArrayLike, DTypeLike, _ArrayLikeVoid_co

_ShapeLike = _nt._ShapeLike

__all__ = [
"array",
Expand Down
3 changes: 2 additions & 1 deletion src/numpy-stubs/_core/umath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ from numpy._typing import (
_DTypeLike as _ToDType,
_DTypeLikeComplex as _ToDTypeComplex,
_DTypeLikeFloat as _ToDTypeFloat,
_ShapeLike,
)
Comment thread
jorenham marked this conversation as resolved.

_ShapeLike = _nt._ShapeLike

from . import _multiarray_umath as _multiarray_umath
from ._multiarray_umath import (
_UFUNC_API as _UFUNC_API,
Expand Down
5 changes: 2 additions & 3 deletions src/numpy-stubs/_typing/_shape.pyi
Comment thread
jorenham marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from collections.abc import Sequence
from typing import SupportsIndex, TypeAlias
import _numtype as _nt

# TODO(jorenham): https://github.com/numpy/numtype/issues/565

# Anything that can be coerced to a shape tuple
_ShapeLike: TypeAlias = SupportsIndex | Sequence[SupportsIndex] # noqa: PYI047
_ShapeLike = _nt._ShapeLike
4 changes: 3 additions & 1 deletion src/numpy-stubs/ctypeslib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import _numtype as _nt
import numpy as np
from numpy._core._internal import _ctypes
from numpy._core.multiarray import flagsobj
from numpy._typing import _ArrayLike, _DTypeLike, _ShapeLike, _VoidDTypeLike
from numpy._typing import _ArrayLike, _DTypeLike, _VoidDTypeLike
from numpy._typing._char_codes import _LongCodes, _ULongCodes

_ShapeLike = _nt._ShapeLike

__all__ = ["as_array", "as_ctypes", "as_ctypes_type", "c_intp", "load_library", "ndpointer"]

###
Expand Down
3 changes: 2 additions & 1 deletion src/numpy-stubs/fft/_helper.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ from typing_extensions import TypeVar

import _numtype as _nt
import numpy as np
from numpy._typing import _ShapeLike

_ShapeLike = _nt._ShapeLike

__all__ = ["fftfreq", "fftshift", "ifftshift", "rfftfreq"]

Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/lib/_function_base_impl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import numpy as np
from numpy import _OrderKACF as _Order # noqa: ICN003
from numpy._core.multiarray import bincount
from numpy._globals import _NoValueType
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike, _DTypeLike, _ShapeLike
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike, _DTypeLike

_ShapeLike = _nt._ShapeLike

__all__ = [
"angle",
Expand Down
3 changes: 2 additions & 1 deletion src/numpy-stubs/lib/_shape_base_impl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from typing_extensions import ParamSpec, TypeVar, deprecated
import _numtype as _nt
import numpy as np
from numpy import _CastingKind # noqa: ICN003
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike as _ToArray, _ShapeLike as _ToShape
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike as _ToArray

__all__ = [
"apply_along_axis",
Expand All @@ -28,6 +28,7 @@ __all__ = [

_Tss = ParamSpec("_Tss")
_ScalarT = TypeVar("_ScalarT", bound=np.generic)
_ToShape: TypeAlias = _nt._ShapeLike

_ArrayList: TypeAlias = list[_nt.Array[_ScalarT]]

Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/lib/_stride_tricks_impl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ from typing_extensions import TypeVar

import _numtype as _nt
import numpy as np
from numpy._typing import ArrayLike, _ArrayLike, _ShapeLike
from numpy._typing import ArrayLike, _ArrayLike

_ShapeLike = _nt._ShapeLike

__all__ = ["broadcast_arrays", "broadcast_shapes", "broadcast_to"]

Expand Down
3 changes: 2 additions & 1 deletion src/numpy-stubs/ma/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ from numpy._typing import (
_ArrayLike,
_DTypeLike,
_ScalarLike_co,
_ShapeLike,
_SupportsArrayFunc as _CanArrayFunc,
_SupportsDType as _HasDType,
_VoidDTypeLike,
)

_ShapeLike = _nt._ShapeLike

__all__ = [
"MAError",
"MaskError",
Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/ma/extras.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ from typing_extensions import TypeVar, override

import _numtype as _nt
import numpy as np
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike, _DTypeLike, _ShapeLike
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike, _DTypeLike
from numpy.lib._function_base_impl import average
from numpy.lib._index_tricks_impl import AxisConcatenator

_ShapeLike = _nt._ShapeLike

from .core import dot

__all__ = [
Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/random/_generator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ from typing_extensions import TypeVar, override
import _numtype as _nt
import numpy as np
import numpy.typing as npt
from numpy._typing import _ArrayLike, _BoolCodes, _DTypeLike, _ShapeLike
from numpy._typing import _ArrayLike, _BoolCodes, _DTypeLike
from numpy.random import BitGenerator, RandomState, SeedSequence

_ShapeLike = _nt._ShapeLike

###

_ScalarT = TypeVar("_ScalarT", bound=np.generic)
Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/random/bit_generator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ from typing_extensions import CapsuleType, TypeVar, override

import _numtype as _nt
import numpy as np
from numpy._typing import _ArrayLikeInt_co, _DTypeLike, _ShapeLike, _UInt32Codes, _UInt64Codes
from numpy._typing import _ArrayLikeInt_co, _DTypeLike, _UInt32Codes, _UInt64Codes

_ShapeLike = _nt._ShapeLike

__all__ = ["BitGenerator", "SeedSequence"]

Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/random/mtrand.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ from typing_extensions import TypeVar, override
import _numtype as _nt
import numpy as np
import numpy.typing as npt
from numpy._typing import _ArrayLike, _BoolCodes, _DTypeLike, _ShapeLike
from numpy._typing import _ArrayLike, _BoolCodes, _DTypeLike
from numpy.random.bit_generator import BitGenerator

_ShapeLike = _nt._ShapeLike

__all__ = [
"RandomState",
"beta",
Expand Down