Skip to content

Commit

Permalink
Codacy fixes and suppressions
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeyiasemis committed Jun 20, 2022
1 parent bbf5579 commit a2bebe8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions direct/common/subsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# https://github.com/facebookresearch/fastMRI/
# The code can have been adjusted to our needs.

# pylint: disable=arguments-differ

import contextlib
import logging
from abc import abstractmethod
Expand Down Expand Up @@ -222,7 +224,6 @@ def mask_func(
raise ValueError("Shape should have 3 or more dimensions")

with temp_seed(self.rng, seed):
num_rows = shape[-3]
num_cols = shape[-2]

center_fraction, acceleration = self.choose_acceleration()
Expand Down Expand Up @@ -300,7 +301,6 @@ def mask_func(
raise ValueError("Shape should have 3 or more dimensions")

with temp_seed(self.rng, seed):
num_rows = shape[-3]
num_cols = shape[-2]

center_fraction, acceleration = self.choose_acceleration()
Expand Down Expand Up @@ -851,7 +851,7 @@ def mask_func(
if seed is None:
# cython requires specific seed type so it cannot be None
cython_seed = self.rng.randint(0, 1e4)
elif isinstance(seed, tuple) or isinstance(seed, list):
elif isinstance(seed, (tuple, list)):
# cython `srand` method takes only integers
cython_seed = int(np.mean(seed))
elif isinstance(seed, int):
Expand All @@ -867,7 +867,7 @@ def mask_func(
try:
mask = self.poisson(num_rows, num_cols, center_fraction, acceleration, cython_seed)
return torch.from_numpy(mask[np.newaxis, ..., np.newaxis])
except Exception as e:
except:
cython_seed += 1
raise ValueError(
f"Cannot generate mask to satisfy R={acceleration}, seed={seed}, max_attempts={self.max_attempts}."
Expand Down Expand Up @@ -896,7 +896,7 @@ def poisson(
seed: int
Seed to be used by cython function. Default: 0.
"""

# pylint: disable=too-many-locals
x, y = np.mgrid[:num_rows, :num_cols]

x = np.maximum(abs(x - num_rows / 2) - self.calibration[0] / 2, 0)
Expand Down

0 comments on commit a2bebe8

Please sign in to comment.