[records] early return if we got an int

This commit is contained in:
jan 2026-03-09 01:00:48 -07:00
commit 966e350f66

View file

@ -173,6 +173,8 @@ class GENERATIONS(Int2Record):
@classmethod @classmethod
def check_data(cls: type[Self], data: NDArray[numpy.integer] | Sequence[int] | int) -> None: def check_data(cls: type[Self], data: NDArray[numpy.integer] | Sequence[int] | int) -> None:
if isinstance(data, (int, numpy.integer)):
return
if not isinstance(data, Sized) or len(data) != 1: if not isinstance(data, Sized) or len(data) != 1:
raise KlamathError(f'Expected exactly one integer, got {data}') raise KlamathError(f'Expected exactly one integer, got {data}')
@ -270,6 +272,8 @@ class FORMAT(Int2Record):
@classmethod @classmethod
def check_data(cls: type[Self], data: NDArray[numpy.integer] | Sequence[int] | int) -> None: def check_data(cls: type[Self], data: NDArray[numpy.integer] | Sequence[int] | int) -> None:
if isinstance(data, (int, numpy.integer)):
return
if not isinstance(data, Sized) or len(data) != 1: if not isinstance(data, Sized) or len(data) != 1:
raise KlamathError(f'Expected exactly one integer, got {data}') raise KlamathError(f'Expected exactly one integer, got {data}')