Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SourceryAI
Copy link

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:

git fetch https://github.com/sourcery-ai-bot/xmca master
git merge --ff-only FETCH_HEAD
git reset HEAD^

if flavour == 'varmx':
elif flavour == 'varmx':
Copy link
Author

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':
Copy link
Author

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':
Copy link
Author

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':
Copy link
Author

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':
Copy link
Author

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)

Comment on lines -533 to +516
if any([np.isnan(field).all() for field in self._fields.values()]):
if any(np.isnan(field).all() for field in self._fields.values()):
Copy link
Author

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:

Comment on lines -619 to +600
if isinstance(n, slice):
max_mode = n.stop
else:
max_mode = n

max_mode = n.stop if isinstance(n, slice) else n
Copy link
Author

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:

Comment on lines -652 to +629
if isinstance(n, slice):
max_mode = n.stop
else:
max_mode = n

max_mode = n.stop if isinstance(n, slice) else n
Copy link
Author

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:

Comment on lines -774 to +751
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
)
Copy link
Author

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:

Comment on lines -826 to +798
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)}
Copy link
Author

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:

Comment on lines -983 to +954
scf = variance**2 / self._analysis['total_squared_covariance'] * 100
return scf
return variance**2 / self._analysis['total_squared_covariance'] * 100
Copy link
Author

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:

Comment on lines -1005 to +975
exp_var = variance / self._analysis['total_covariance'] * 100
return exp_var
return variance / self._analysis['total_covariance'] * 100
Copy link
Author

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:

Comment on lines -1120 to +1089
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()}
Copy link
Author

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:

Comment on lines -1182 to +1147
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()}
Copy link
Author

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:

Comment on lines -1593 to +1554
if path is None:
output = 'mode{:}.png'.format(mode)
else:
output = path

output = 'mode{:}.png'.format(mode) if path is None else path
Copy link
Author

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:

Comment on lines -970 to +972
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)
Copy link
Author

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:

nan_index = np.isnan(arr).any(axis=0)

return nan_index
return np.isnan(arr).any(axis=0)
Copy link
Author

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:

Comment on lines -60 to +58
new_arr = arr[:, ~idx]

return new_arr
return arr[:, ~idx]
Copy link
Author

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:

for i in range(maxIter):
for _ in range(maxIter):
Copy link
Author

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:

if(isinstance(data, xr.DataArray)):
pass
else:
if not (isinstance(data, xr.DataArray)):
Copy link
Author

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:

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