Skip to content

Sourcery Starbot ⭐ refactored nicrie/xmca#26

Open
SourceryAI wants to merge 1 commit intonicrie:mainfrom
SourceryAI:master
Open

Sourcery Starbot ⭐ refactored nicrie/xmca#26
SourceryAI wants to merge 1 commit intonicrie:mainfrom
SourceryAI:master

Conversation

@SourceryAI
Copy link
Copy Markdown

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 == 'cplx':
cplx = True
if flavour == 'varmx':
elif flavour == 'varmx':
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 TestIntegration.test_plot refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

if analysis == 'cplx':
cplx = True
if analysis == 'varmx':
elif analysis == 'varmx':
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 TestIntegration.test_getter refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

if analysis == 'cplx':
cplx = True
if analysis == 'varmx':
elif analysis == 'varmx':
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 TestIntegration.test_hom_het_patterns refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

if analysis == 'cplx':
cplx = True
if analysis == 'varmx':
elif analysis == 'varmx':
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 TestIntegration.test_field refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

if analysis == 'cplx':
cplx = True
if analysis == 'varmx':
elif analysis == 'varmx':
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 TestIntegration.test_field_scaling refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/array.py
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
Copy Markdown
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 thread xmca/xarray.py
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
Copy Markdown
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:

Comment thread xmca/tools/array.py
nan_index = np.isnan(arr).any(axis=0)

return nan_index
return np.isnan(arr).any(axis=0)
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_nan_cols refactored with the following changes:

Comment thread xmca/tools/array.py
Comment on lines -60 to +58
new_arr = arr[:, ~idx]

return new_arr
return arr[:, ~idx]
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 remove_nan_cols refactored with the following changes:

Comment thread xmca/tools/rotation.py
# seek for rotation matrix based on varimax criteria
converged = False
for i in range(maxIter):
for _ in range(maxIter):
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 varimax refactored with the following changes:

Comment thread xmca/tools/xarray.py
if(isinstance(data, xr.DataArray)):
pass
else:
if not (isinstance(data, xr.DataArray)):
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 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