-
Notifications
You must be signed in to change notification settings - Fork 16
Sourcery Starbot ⭐ refactored nicrie/xmca #26
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
base: main
Are you sure you want to change the base?
Conversation
if flavour == 'varmx': | ||
elif flavour == 'varmx': |
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 TestIntegration.test_plot
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
)
if analysis == 'varmx': | ||
elif analysis == 'varmx': |
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 TestIntegration.test_getter
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
)
if analysis == 'varmx': | ||
elif analysis == 'varmx': |
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 TestIntegration.test_hom_het_patterns
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
)
if analysis == 'varmx': | ||
elif analysis == 'varmx': |
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 TestIntegration.test_field
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
)
if analysis == 'varmx': | ||
elif analysis == 'varmx': |
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 TestIntegration.test_field_scaling
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
)
if any([np.isnan(field).all() for field in self._fields.values()]): | ||
if any(np.isnan(field).all() for field in self._fields.values()): |
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 MCA.solve
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
) - Replace unneeded comprehension with generator (
comprehension-to-generator
)
if isinstance(n, slice): | ||
max_mode = n.stop | ||
else: | ||
max_mode = n | ||
|
||
max_mode = n.stop if isinstance(n, slice) else n |
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 MCA._get_V
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if isinstance(n, slice): | ||
max_mode = n.stop | ||
else: | ||
max_mode = n | ||
|
||
max_mode = n.stop if isinstance(n, slice) else n |
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 MCA._get_U
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if self._analysis['is_bivariate']: | ||
var = norm['left'] * norm['right'] | ||
else: | ||
var = norm['left']**2 | ||
|
||
return var | ||
return ( | ||
norm['left'] * norm['right'] | ||
if self._analysis['is_bivariate'] | ||
else norm['left'] ** 2 | ||
) |
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 MCA._get_variance
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
norm = {} | ||
norm['left'] = np.linalg.norm(L_rot[:n_vars_left, :], axis=0) | ||
norm = {'left': np.linalg.norm(L_rot[:n_vars_left, :], 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 MCA.rotate
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
)
scf = variance**2 / self._analysis['total_squared_covariance'] * 100 | ||
return scf | ||
return variance**2 / self._analysis['total_squared_covariance'] * 100 |
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 MCA.scf
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
exp_var = variance / self._analysis['total_covariance'] * 100 | ||
return exp_var | ||
return variance / self._analysis['total_covariance'] * 100 |
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 MCA.explained_variance
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
phases = {} | ||
for key, eof in eofs.items(): | ||
phases[key] = np.arctan2(eof.imag, eof.real).real | ||
|
||
return phases | ||
return {key: np.arctan2(eof.imag, eof.real).real for key, eof in eofs.items()} |
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 MCA.spatial_phase
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
phases = {} | ||
for key, pc in pcs.items(): | ||
phases[key] = np.arctan2(pc.imag, pc.real).real | ||
|
||
return phases | ||
return {key: np.arctan2(pc.imag, pc.real).real for key, pc in pcs.items()} |
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 MCA.temporal_phase
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if path is None: | ||
output = 'mode{:}.png'.format(mode) | ||
else: | ||
output = path | ||
|
||
output = 'mode{:}.png'.format(mode) if path is None else path |
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 MCA.save_plot
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if k1 in ['eof', 'phase']: | ||
if k2 in ['left', 'right']: | ||
map_projs[k1][k2] = projection.get(k2, None) | ||
if k1 in ['eof', 'phase'] and k2 in ['left', 'right']: | ||
map_projs[k1][k2] = projection.get(k2, 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 xMCA._create_gridspec
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
nan_index = np.isnan(arr).any(axis=0) | ||
|
||
return nan_index | ||
return np.isnan(arr).any(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 get_nan_cols
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
new_arr = arr[:, ~idx] | ||
|
||
return new_arr | ||
return arr[:, ~idx] |
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 remove_nan_cols
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
for i in range(maxIter): | ||
for _ in range(maxIter): |
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 varimax
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
if(isinstance(data, xr.DataArray)): | ||
pass | ||
else: | ||
if not (isinstance(data, xr.DataArray)): |
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 is_DataArray
refactored with the following changes:
- Swap if/else to remove empty if body (
remove-pass-body
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: