Skip to content

Commit

Permalink
[MONAI] code formatting
Browse files Browse the repository at this point in the history
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
  • Loading branch information
monai-bot committed Feb 13, 2023
1 parent 6f404a9 commit 9762097
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions monai/apps/detection/transforms/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ def __init__(self, spatial_size: Sequence[int] | int, size_mode: str = "all", **
self.size_mode = look_up_option(size_mode, ["all", "longest"])
self.spatial_size = spatial_size

def __call__(self, boxes: NdarrayOrTensor, src_spatial_size: Sequence[int] | int) -> NdarrayOrTensor: # type: ignore[override]
# type: ignore[override]
def __call__(self, boxes: NdarrayOrTensor, src_spatial_size: Sequence[int] | int) -> NdarrayOrTensor:
"""
Args:
boxes: source bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
Expand Down Expand Up @@ -533,7 +534,8 @@ class RotateBox90(Rotate90):

backend = [TransformBackends.TORCH, TransformBackends.NUMPY]

def __call__(self, boxes: NdarrayTensor, spatial_size: Sequence[int] | int) -> NdarrayTensor: # type: ignore[override]
# type: ignore[override]
def __call__(self, boxes: NdarrayTensor, spatial_size: Sequence[int] | int) -> NdarrayTensor:
"""
Args:
img: channel first array, must have shape: (num_channels, H[, W, ..., ]),
Expand Down
4 changes: 3 additions & 1 deletion monai/apps/detection/transforms/box_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def flip_boxes(
flip_axes = ensure_tuple(flip_axes)

# flip box
_flip_boxes: NdarrayTensor = boxes.clone() if isinstance(boxes, torch.Tensor) else deepcopy(boxes) # type: ignore[assignment]
_flip_boxes: NdarrayTensor = (
boxes.clone() if isinstance(boxes, torch.Tensor) else deepcopy(boxes)
) # type: ignore[assignment]

for axis in flip_axes:
_flip_boxes[:, axis + spatial_dims] = spatial_size[axis] - boxes[:, axis] - TO_REMOVE
Expand Down
3 changes: 2 additions & 1 deletion monai/metrics/rocauc.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def __init__(self, average: Average | str = Average.MACRO) -> None:
super().__init__()
self.average = average

def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]: # type: ignore[override]
# type: ignore[override]
def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
return y_pred, y

def aggregate(self, average: Average | str | None = None) -> np.ndarray | float | npt.ArrayLike:
Expand Down
8 changes: 6 additions & 2 deletions monai/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ def get_mask_edges(
seg_pred, seg_gt = np.expand_dims(seg_pred, axis=channel_dim), np.expand_dims(seg_gt, axis=channel_dim)
box_start, box_end = generate_spatial_bounding_box(np.asarray(seg_pred | seg_gt))
cropper = SpatialCrop(roi_start=box_start, roi_end=box_end)
seg_pred = convert_data_type(np.squeeze(cropper(seg_pred), axis=channel_dim), np.ndarray)[0] # type: ignore[arg-type]
seg_gt = convert_data_type(np.squeeze(cropper(seg_gt), axis=channel_dim), np.ndarray)[0] # type: ignore[arg-type]
seg_pred = convert_data_type(np.squeeze(cropper(seg_pred), axis=channel_dim), np.ndarray)[
0
] # type: ignore[arg-type]
seg_gt = convert_data_type(np.squeeze(cropper(seg_gt), axis=channel_dim), np.ndarray)[
0
] # type: ignore[arg-type]

# Do binary erosion and use XOR to get edges
edges_pred = binary_erosion(seg_pred) ^ seg_pred
Expand Down

0 comments on commit 9762097

Please sign in to comment.