MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / allclose

Function allclose

monai/transforms/utils_pytorch_numpy_unification.py:72–77  ·  view source on GitHub ↗

`np.allclose` with equivalent implementation for torch.

(a: NdarrayTensor, b: NdarrayOrTensor, rtol=1e-5, atol=1e-8, equal_nan=False)

Source from the content-addressed store, hash-verified

70
71
72def allclose(a: NdarrayTensor, b: NdarrayOrTensor, rtol=1e-5, atol=1e-8, equal_nan=False) -> bool:
73 """`np.allclose` with equivalent implementation for torch."""
74 b, *_ = convert_to_dst_type(b, a, wrap_sequence=True)
75 if isinstance(a, np.ndarray):
76 return np.allclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan)
77 return torch.allclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan) # type: ignore
78
79
80def moveaxis(x: NdarrayOrTensor, src: int | Sequence[int], dst: int | Sequence[int]) -> NdarrayOrTensor:

Callers 2

resampleFunction · 0.90
spatial_resampleFunction · 0.90

Calls 1

convert_to_dst_typeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…