Skip to content

Sourcery refactored master branch - #3

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

Sourcery refactored master branch#3
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Jun 1, 2020

Copy link
Copy Markdown

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai
sourcery-ai Bot force-pushed the sourcery/master branch from c49784b to b0c868b Compare June 1, 2020 10:29
@sourcery-ai
sourcery-ai Bot force-pushed the sourcery/master branch from b0c868b to 872c410 Compare June 1, 2020 10:35
Comment thread hubconf.py
from highresnet import HighRes2DNet
model = HighRes2DNet(*args, **kwargs)
return model
return HighRes2DNet(*args, **kwargs)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function highres2dnet refactored with the following changes:

  • Inline variable that is only used once

Comment thread highresnet/histogram.py
masked_img = ma.masked_array(img, np.logical_not(mask)).compressed()
perc_results = np.percentile(masked_img, 100 * np.array(perc))
return perc_results
return np.percentile(masked_img, 100 * np.array(perc))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function __compute_percentiles refactored with the following changes:

  • Inline variable that is only used once

Comment thread highresnet/inference.py
print(f'Detected spacing: {spacing}. Resampling to 1 mm iso...')
needs_resampling = not is_ras or not is_1_iso
return needs_resampling
return not is_ras or not is_1_iso

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_header refactored with the following changes:

  • Inline variable that is only used once

Comment thread highresnet/inference.py
Comment on lines -140 to +139
model = torch.hub.load(repo, model_name, pretrained=True)
return model
return torch.hub.load(repo, model_name, pretrained=True)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_model refactored with the following changes:

  • Inline variable that is only used once

sitk.WriteImage(resampled, temp_path)
nifti_resampled = nib.load(temp_path)
return nifti_resampled
return nib.load(temp_path)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function resample_spacing refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -98 to +101
nii_resampled = resample_spacing(
nii_ras,
output_spacing=one_iso,
interpolation=interpolation,
)
return nii_resampled
return resample_spacing(
nii_ras,
output_spacing=one_iso,
interpolation=interpolation,
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function resample_ras_1mm_iso refactored with the following changes:

  • Inline variable that is only used once

Comment thread highresnet/sampling.py
Comment on lines -27 to +30
sample = dict(
image=window,
location=location,
)
return sample
return dict(
image=window,
location=location,
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GridSampler.__getitem__ refactored with the following changes:

  • Inline variable that is only used once

input_output_diff = (3 - 1) + torch.sum(B * N * 2 ** (d + 1))
receptive_field = input_output_diff + 1
return receptive_field
return input_output_diff + 1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function HighResNet.receptive_field refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -31 to +39
if self.change_dimension:
if residual_type == 'project':
conv_class = nn.Conv2d if dimensions == 2 else nn.Conv3d
self.change_dim_layer = conv_class(
in_channels,
out_channels,
kernel_size=1,
dilation=dilation,
bias=False, # as in NiftyNet and PyTorch's ResNet model
)
if self.change_dimension and residual_type == 'project':
conv_class = nn.Conv2d if dimensions == 2 else nn.Conv3d
self.change_dim_layer = conv_class(
in_channels,
out_channels,
kernel_size=1,
dilation=dilation,
bias=False, # as in NiftyNet and PyTorch's ResNet model
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResidualBlock.__init__ refactored with the following changes:

  • Merge nested if conditions

config.read_string(config_string)
data_url = config['data']['url']
return data_url
return config['data']['url']

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_data_url_from_model_zoo refactored with the following changes:

  • Inline variable that is only used once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant