-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from functools import singledispatch | ||
from typing import Any, List, Union | ||
|
||
import numpy as np | ||
import xarray as xr | ||
from numpy.typing import NDArray | ||
|
||
from bioimageio.spec.model import v0_4, v0_5 | ||
from bioimageio.spec.utils import download | ||
|
||
# @singledispatch | ||
# def is_valid_tensor(description: object, tensor: Union[NDArray[Any], xr.DataArray]) -> bool: | ||
# raise NotImplementedError(type(description)) | ||
|
||
# is_valid_tensor.register | ||
# def _(description: v0_4.InputTensor, tensor: Union[NDArray[Any], xr.DataArray]): | ||
|
||
|
||
@singledispatch | ||
def get_test_input_tensors(model: object) -> List[xr.DataArray]: | ||
raise NotImplementedError(type(model)) | ||
|
||
|
||
@get_test_input_tensors.register | ||
def _(model: v0_4.Model): | ||
data = [np.load(download(ipt).path) for ipt in model.test_inputs] | ||
assert all(isinstance(d, np.ndarray) for d in data) | ||
|
||
|
||
# @get_test_input_tensors.register | ||
# def _(model: v0_5.Model): |