-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #28
Conversation
ext.define_macros = [ | ||
("VERSION_INFO", | ||
'"{}"'.format(self.distribution.get_version())) | ||
] | ||
ext.define_macros = [("VERSION_INFO", f'"{self.distribution.get_version()}"')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function BuildExt.build_extensions
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
if effective: | ||
Keff = self.Ku - (0.5 * mu0) * (self.Ms**2) | ||
else: | ||
Keff = self.Ku | ||
Keff = self.Ku - (0.5 * mu0) * (self.Ms**2) if effective else self.Ku |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function DomainWallDynamics.get_unrelaxed_domain_width
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
sum_ = 0 | ||
for x_ in x: | ||
sum_ += x_**2 | ||
sum_ = sum(x_**2 for x_ in x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function fast_norm
refactored with the following changes:
- Convert for loop into call to sum() (
sum-comprehension
)
all_symbols.append(sym.Symbol(r"\theta_" + indx_i)) | ||
all_symbols.append(sym.Symbol(r"\phi_" + indx_i)) | ||
all_symbols.extend( | ||
(sym.Symbol(r"\theta_" + indx_i), sym.Symbol(r"\phi_" + indx_i)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function general_hessian_functional
refactored with the following changes:
- Merge consecutive list appends into a single extend (
merge-list-appends-into-extend
)
s1 = sym.Symbol(r"\theta_" + indx_i) | ||
s2 = sym.Symbol(r"\phi_" + indx_j) | ||
expr = sym.diff(energy_functional_expr, s1, s2) | ||
if i == j: | ||
s1 = sym.Symbol(r"\theta_" + indx_i) | ||
s2 = sym.Symbol(r"\phi_" + indx_j) | ||
expr = sym.diff(energy_functional_expr, s1, s2) | ||
hessian[2 * i + 1][2 * j] = expr + sym.I * z | ||
hessian[2 * i][2 * j + 1] = expr - sym.I * z | ||
else: | ||
s1 = sym.Symbol(r"\theta_" + indx_i) | ||
s2 = sym.Symbol(r"\phi_" + indx_j) | ||
expr = sym.diff(energy_functional_expr, s1, s2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_hessian_from_energy_expr
refactored with the following changes:
- Hoist repeated code outside conditional statement [×3] (
hoist-statement-from-if
)
y = lfilter(b, a, data, zi=None) | ||
return y | ||
return lfilter(b, a, data, zi=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Filters.butter_bandpass_filter
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
y = lfilter(b, a, data, zi=None) | ||
return y | ||
return lfilter(b, a, data, zi=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Filters.butter_lowpass_filter
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if axis: | ||
detrended = (arr.T - medians).T | ||
else: | ||
detrended = arr - medians | ||
return detrended | ||
return (arr.T - medians).T if axis else arr - medians |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Filters.detrend_axis
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
axes = [host] + [host.twinx() for i in range(ys.shape[1] - 1)] | ||
axes = [host] + [host.twinx() for _ in range(ys.shape[1] - 1)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function create_coordinates_plot
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
) - Replace identity comprehension with call to collection constructor (
identity-comprehension
) - Replace if statement with if expression (
assign-if-exp
)
if not (angle is None): | ||
if angle is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function create_stack
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
R = Rp + 0.5 * (Rap - Rp) * np.sum(m[0] * m[1], axis=0) | ||
return R | ||
return Rp + 0.5 * (Rap - Rp) * np.sum(m[0] * m[1], axis=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function calculate_magnetoresistance
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if sol.success: | ||
return sol.x[0] | ||
return None | ||
return sol.x[0] if sol.success else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function RootFinder.find_root
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
@@ -85,7 +85,6 @@ def __init__(self, | |||
else: | |||
raise ValueError(f"Unknown loss type: {loss_type}") | |||
|
|||
infeat = 2998 * 80 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PhysicsModel.__init__
refactored with the following changes:
- Remove unreachable code (
remove-unreachable-code
)
opt = torch.optim.Adam(self.parameters(), lr=self.hparams.lr) | ||
return opt | ||
return torch.optim.Adam(self.parameters(), lr=self.hparams.lr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PhysicsModel.configure_optimizers
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
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:Help us improve this pull request!