Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion monai/metrics/fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _cov(input_data: torch.Tensor, rowvar: bool = True) -> torch.Tensor:

def _sqrtm(input_data: torch.Tensor) -> torch.Tensor:
"""Compute the square root of a matrix."""
scipy_res, _ = scipy.linalg.sqrtm(input_data.detach().cpu().numpy().astype(np.float_), disp=False)
scipy_res, _ = scipy.linalg.sqrtm(input_data.detach().cpu().numpy().astype(np.float64), disp=False)
return torch.from_numpy(scipy_res)


Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/utils_pytorch_numpy_unification.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def moveaxis(x: NdarrayOrTensor, src: int | Sequence[int], dst: int | Sequence[i
def in1d(x, y):
"""`np.in1d` with equivalent implementation for torch."""
if isinstance(x, np.ndarray):
return np.in1d(x, y)
return np.isin(x, y)
return (x[..., None] == torch.tensor(y, device=x.device)).any(-1).view(-1)


Expand Down
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ exclude = "monai/bundle/__main__.py"

[tool.ruff]
line-length = 133
lint.ignore = ["F401", "E741"]
target-version = "py39"

[tool.ruff.lint]
select = [
"E", "F", "W", # flake8
"NPY", # NumPy specific rules
]
extend-ignore = [
"E741", # ambiguous variable name
"F401", # unused import
"NPY002", # numpy-legacy-random
]

[tool.pytype]
# Space-separated list of files or directories to exclude.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_compute_f_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_with_nan_values(self):
metric = FBetaScore(get_not_nans=True)
metric(
y_pred=torch.Tensor([[1, 1, 1], [1, 1, 1], [1, 1, 1]]),
y=torch.Tensor([[1, 0, 1], [np.NaN, np.NaN, np.NaN], [1, 0, 1]]),
y=torch.Tensor([[1, 0, 1], [np.nan, np.nan, np.nan], [1, 0, 1]]),
)
assert_allclose(metric.aggregate()[0][0], torch.Tensor([0.727273]), atol=1e-6, rtol=1e-6)

Expand Down