update changelog, bump version

This commit is contained in:
sneakers-the-rat 2024-08-12 21:35:01 -07:00
parent e9d766aad1
commit a8ba11f772
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
2 changed files with 13 additions and 1 deletions

View file

@ -128,7 +128,13 @@ class Interface(ABC, Generic[T]):
elif self.dtype is np.str_:
valid = getattr(dtype, "type", None) is np.str_ or dtype is np.str_
else:
valid = dtype == self.dtype
# try to match as any subclass, if self.dtype is a class
try:
valid = issubclass(dtype, self.dtype)
except TypeError:
# expected, if dtype or self.dtype is not a class
valid = dtype == self.dtype
return valid
def raise_for_dtype(self, valid: bool, dtype: DtypeType) -> None:

View file

@ -66,6 +66,10 @@ class BadModel(BaseModel):
x: int
class SubClass(BasicModel):
pass
RGB_UNION: TypeAlias = Union[
NDArray[Shape["* x, * y"], Number],
NDArray[Shape["* x, * y, 3 r_g_b"], Number],
@ -143,6 +147,7 @@ def shape_cases(request) -> ValidationCase:
ValidationCase(annotation=MODEL, dtype=BasicModel, passes=True),
ValidationCase(annotation=MODEL, dtype=BadModel, passes=False),
ValidationCase(annotation=MODEL, dtype=int, passes=False),
ValidationCase(annotation=MODEL, dtype=SubClass, passes=True),
],
ids=[
"float",
@ -169,6 +174,7 @@ def shape_cases(request) -> ValidationCase:
"model-model",
"model-badmodel",
"model-int",
"model-subclass",
],
)
def dtype_cases(request) -> ValidationCase: