update old numpy dtypes, remove them, lint

This commit is contained in:
sneakers-the-rat 2024-07-31 14:15:24 -07:00
parent 4604e7e7bb
commit 3306703741
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
12 changed files with 33 additions and 52 deletions

View file

@ -101,6 +101,10 @@ select = [
"I", "I",
# annotations # annotations
"ANN", "ANN",
# perf
"PERF",
# numpy
"NPY",
## ---------- ## ----------
# pydocstyle # pydocstyle
# undocumented public objects # undocumented public objects

View file

@ -69,9 +69,7 @@ Half = np.half
Single = np.single Single = np.single
Double = np.double Double = np.double
LongDouble = np.longdouble LongDouble = np.longdouble
LongFloat = np.longfloat
Float = ( Float = (
np.float_,
np.float16, np.float16,
np.float32, np.float32,
np.float64, np.float64,
@ -84,32 +82,24 @@ ComplexFloating = np.complexfloating
Complex64 = np.complex64 Complex64 = np.complex64
Complex128 = np.complex128 Complex128 = np.complex128
CSingle = np.csingle CSingle = np.csingle
SingleComplex = np.singlecomplex
CDouble = np.cdouble CDouble = np.cdouble
CFloat = np.cfloat
CLongDouble = np.clongdouble CLongDouble = np.clongdouble
CLongFloat = np.clongfloat
Complex = ( Complex = (
np.complex_,
np.complexfloating, np.complexfloating,
np.complex64, np.complex64,
np.complex128, np.complex128,
np.csingle, np.csingle,
np.singlecomplex,
np.cdouble, np.cdouble,
np.cfloat,
np.clongdouble, np.clongdouble,
np.clongfloat,
) )
LongComplex = np.longcomplex
Flexible = np.flexible Flexible = np.flexible
Void = np.void Void = np.void
Character = np.character Character = np.character
Bytes = np.bytes_ Bytes = np.bytes_
Str = np.str_ Str = np.str_
String = np.string_ String = np.str_
Unicode = np.unicode_ Unicode = np.str_
Number = tuple( Number = tuple(
[ [

View file

@ -144,9 +144,9 @@ class VideoProxy:
elif isinstance(item, slice): elif isinstance(item, slice):
# slice of frames # slice of frames
item = self._complete_slice(item) item = self._complete_slice(item)
frames = [] frames = [
for i in range(item.start, item.stop, item.step): self._get_frame(i) for i in range(item.start, item.stop, item.step)
frames.append(self._get_frame(i)) ]
return np.stack(frames) return np.stack(frames)
else: else:
# slices are passed as tuples # slices are passed as tuples

View file

@ -21,7 +21,7 @@ np_to_python = {
**{n: int for n in dt.Integer}, **{n: int for n in dt.Integer},
**{n: float for n in dt.Float}, **{n: float for n in dt.Float},
**{n: complex for n in dt.Complex}, **{n: complex for n in dt.Complex},
**{n: str for n in (np.character, np.str_, np.string_, np.unicode_)}, **{n: str for n in (np.character, np.str_, np.bytes_, np.str_)},
} }
"""Map from python types to numpy""" """Map from python types to numpy"""

View file

@ -16,14 +16,6 @@ Extension of nptyping NDArray for pydantic that allows for JSON-Schema serializa
from typing import TYPE_CHECKING, Any, Tuple from typing import TYPE_CHECKING, Any, Tuple
import numpy as np import numpy as np
from numpydantic.vendor.nptyping.error import InvalidArgumentsError
from numpydantic.vendor.nptyping.ndarray import NDArrayMeta as _NDArrayMeta
from numpydantic.vendor.nptyping.nptyping_type import NPTypingType
from numpydantic.vendor.nptyping.structure import Structure
from numpydantic.vendor.nptyping.structure_expression import check_type_names
from numpydantic.vendor.nptyping.typing_ import (
dtype_per_name,
)
from pydantic import GetJsonSchemaHandler from pydantic import GetJsonSchemaHandler
from pydantic_core import core_schema from pydantic_core import core_schema
@ -38,6 +30,14 @@ from numpydantic.schema import (
make_json_schema, make_json_schema,
) )
from numpydantic.types import DtypeType, ShapeType from numpydantic.types import DtypeType, ShapeType
from numpydantic.vendor.nptyping.error import InvalidArgumentsError
from numpydantic.vendor.nptyping.ndarray import NDArrayMeta as _NDArrayMeta
from numpydantic.vendor.nptyping.nptyping_type import NPTypingType
from numpydantic.vendor.nptyping.structure import Structure
from numpydantic.vendor.nptyping.structure_expression import check_type_names
from numpydantic.vendor.nptyping.typing_ import (
dtype_per_name,
)
if TYPE_CHECKING: # pragma: no cover if TYPE_CHECKING: # pragma: no cover
from nptyping.base_meta_classes import SubscriptableMeta from nptyping.base_meta_classes import SubscriptableMeta

View file

@ -7,7 +7,6 @@ import hashlib
import json import json
from typing import TYPE_CHECKING, Any, Callable, Optional, Union from typing import TYPE_CHECKING, Any, Callable, Optional, Union
from numpydantic.vendor.nptyping.structure import StructureMeta
import numpy as np import numpy as np
from pydantic import SerializationInfo from pydantic import SerializationInfo
from pydantic_core import CoreSchema, core_schema from pydantic_core import CoreSchema, core_schema
@ -17,6 +16,7 @@ from numpydantic import dtype as dt
from numpydantic.interface import Interface from numpydantic.interface import Interface
from numpydantic.maps import np_to_python from numpydantic.maps import np_to_python
from numpydantic.types import DtypeType, NDArrayType, ShapeType from numpydantic.types import DtypeType, NDArrayType, ShapeType
from numpydantic.vendor.nptyping.structure import StructureMeta
if TYPE_CHECKING: if TYPE_CHECKING:
from numpydantic import Shape from numpydantic import Shape

View file

@ -8,7 +8,7 @@ Note that these are types as in python typing types, not classes.
from typing import Any, Protocol, Tuple, Union, runtime_checkable from typing import Any, Protocol, Tuple, Union, runtime_checkable
from nptyping import DType from numpydantic.vendor.nptyping import DType
ShapeType = Union[Tuple[int, ...], Any] ShapeType = Union[Tuple[int, ...], Any]
DtypeType = Union[str, type, Any, DType] DtypeType = Union[str, type, Any, DType]

View file

@ -23,12 +23,11 @@ SOFTWARE.
""" """
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from inspect import FrameInfo, getframeinfo from inspect import getframeinfo
from types import FrameType from types import FrameType
from typing import ( from typing import (
Any, Any,
Dict, Dict,
List,
Optional, Optional,
Set, Set,
Tuple, Tuple,

View file

@ -27,6 +27,7 @@ from abc import ABC
from typing import Any, Tuple from typing import Any, Tuple
import numpy as np import numpy as np
from numpydantic.vendor.nptyping.base_meta_classes import ( from numpydantic.vendor.nptyping.base_meta_classes import (
FinalMeta, FinalMeta,
ImmutableMeta, ImmutableMeta,

View file

@ -27,6 +27,7 @@ from abc import ABC
from typing import Any, Tuple from typing import Any, Tuple
import numpy as np import numpy as np
from numpydantic.vendor.nptyping import InvalidArgumentsError from numpydantic.vendor.nptyping import InvalidArgumentsError
from numpydantic.vendor.nptyping.base_meta_classes import ( from numpydantic.vendor.nptyping.base_meta_classes import (
FinalMeta, FinalMeta,

View file

@ -38,6 +38,7 @@ from typing import (
) )
import numpy as np import numpy as np
from numpydantic.vendor.nptyping.error import InvalidShapeError, InvalidStructureError from numpydantic.vendor.nptyping.error import InvalidShapeError, InvalidStructureError
from numpydantic.vendor.nptyping.shape import Shape from numpydantic.vendor.nptyping.shape import Shape
from numpydantic.vendor.nptyping.shape_expression import ( from numpydantic.vendor.nptyping.shape_expression import (

View file

@ -22,7 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
""" """
from typing import ( # type: ignore[attr-defined,misc] # pylint: disable=unused-import from typing import ( # type: ignore[attr-defined,misc] # pylint: disable=unused-import
Tuple, Tuple,
TypeAlias, TypeAlias,
@ -38,10 +37,8 @@ ShapeTuple: TypeAlias = Tuple[int, ...]
Number = np.number Number = np.number
Bool = np.bool_ Bool = np.bool_
Bool8 = np.bool8
Obj = np.object_ # Obj is a common abbreviation and should be usable. Obj = np.object_ # Obj is a common abbreviation and should be usable.
Object = np.object_ Object = np.object_
Object0 = np.object0
Datetime64 = np.datetime64 Datetime64 = np.datetime64
Integer = np.integer Integer = np.integer
SignedInteger = np.signedinteger SignedInteger = np.signedinteger
@ -53,7 +50,6 @@ Byte = np.byte
Short = np.short Short = np.short
IntC = np.intc IntC = np.intc
IntP = np.intp IntP = np.intp
Int0 = np.int0
Int = np.integer # Int should translate to the "generic" int type. Int = np.integer # Int should translate to the "generic" int type.
Int_ = np.int_ Int_ = np.int_
LongLong = np.longlong LongLong = np.longlong
@ -67,7 +63,6 @@ UByte = np.ubyte
UShort = np.ushort UShort = np.ushort
UIntC = np.uintc UIntC = np.uintc
UIntP = np.uintp UIntP = np.uintp
UInt0 = np.uint0
UInt = np.uint UInt = np.uint
ULongLong = np.ulonglong ULongLong = np.ulonglong
Inexact = np.inexact Inexact = np.inexact
@ -78,38 +73,33 @@ Float64 = np.float64
Half = np.half Half = np.half
Single = np.single Single = np.single
Double = np.double Double = np.double
Float = np.float_ Float = np.float64
LongDouble = np.longdouble LongDouble = np.longdouble
LongFloat = np.longfloat LongFloat = np.longdouble
ComplexFloating = np.complexfloating ComplexFloating = np.complexfloating
Complex64 = np.complex64 Complex64 = np.complex64
Complex128 = np.complex128 Complex128 = np.complex128
CSingle = np.csingle CSingle = np.csingle
SingleComplex = np.singlecomplex SingleComplex = np.complex64
CDouble = np.cdouble CDouble = np.cdouble
Complex = np.complex_ Complex = np.complex128
CFloat = np.cfloat CFloat = np.complex128
CLongDouble = np.clongdouble CLongDouble = np.clongdouble
CLongFloat = np.clongfloat CLongFloat = np.clongdouble
LongComplex = np.longcomplex LongComplex = np.clongdouble
Flexible = np.flexible Flexible = np.flexible
Void = np.void Void = np.void
Void0 = np.void0
Character = np.character Character = np.character
Bytes = np.bytes_ Bytes = np.bytes_
Str = np.str_ Str = np.str_
String = np.string_ String = np.str_
Bytes0 = np.bytes0 Unicode = np.str_
Unicode = np.unicode_
Str0 = np.str0
dtypes = [ dtypes = [
(Number, "Number"), (Number, "Number"),
(Bool, "Bool"), (Bool, "Bool"),
(Bool8, "Bool8"),
(Obj, "Obj"), (Obj, "Obj"),
(Object, "Object"), (Object, "Object"),
(Object0, "Object0"),
(Datetime64, "Datetime64"), (Datetime64, "Datetime64"),
(Integer, "Integer"), (Integer, "Integer"),
(SignedInteger, "SignedInteger"), (SignedInteger, "SignedInteger"),
@ -121,7 +111,6 @@ dtypes = [
(Short, "Short"), (Short, "Short"),
(IntC, "IntC"), (IntC, "IntC"),
(IntP, "IntP"), (IntP, "IntP"),
(Int0, "Int0"),
(Int, "Int"), (Int, "Int"),
(LongLong, "LongLong"), (LongLong, "LongLong"),
(Timedelta64, "Timedelta64"), (Timedelta64, "Timedelta64"),
@ -134,7 +123,6 @@ dtypes = [
(UShort, "UShort"), (UShort, "UShort"),
(UIntC, "UIntC"), (UIntC, "UIntC"),
(UIntP, "UIntP"), (UIntP, "UIntP"),
(UInt0, "UInt0"),
(UInt, "UInt"), (UInt, "UInt"),
(ULongLong, "ULongLong"), (ULongLong, "ULongLong"),
(Inexact, "Inexact"), (Inexact, "Inexact"),
@ -161,14 +149,11 @@ dtypes = [
(LongComplex, "LongComplex"), (LongComplex, "LongComplex"),
(Flexible, "Flexible"), (Flexible, "Flexible"),
(Void, "Void"), (Void, "Void"),
(Void0, "Void0"),
(Character, "Character"), (Character, "Character"),
(Bytes, "Bytes"), (Bytes, "Bytes"),
(String, "String"), (String, "String"),
(Str, "Str"), (Str, "Str"),
(Bytes0, "Bytes0"),
(Unicode, "Unicode"), (Unicode, "Unicode"),
(Str0, "Str0"),
] ]
name_per_dtype = dict(dtypes) name_per_dtype = dict(dtypes)