-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Sourcery Starbot ⭐ refactored curenosm/MeIA #3
base: develop
Are you sure you want to change the base?
Conversation
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.
Due to GitHub API limits, only the first 60 comments can be shown.
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
for i, (train_index, test_index) in enumerate(skf.split(x, y)): | ||
|
||
for train_index, test_index in skf.split(x, y): |
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 kfcv
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
) - Replace unused for index with underscore (
for-index-underscore
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Replace unused for index with underscore (
for-index-underscore
) - Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
print("Loading data from %s" % (data_file)) | ||
print(f"Loading data from {data_file}") | ||
|
||
dataMat = scipy.io.loadmat(data_file, mat_dtype=True) | ||
all_data = np.array(dataMat['features']) | ||
|
||
data = np.array(all_data[:,:len(all_data[0])-1]) | ||
labels = np.array(all_data[:,len(all_data[0])-1]) | ||
|
||
print("Data loading complete. Shape is %r" % (dataMat['features'].shape,)) | ||
|
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 load_data
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
print("Loading data from %s" % (data_file)) | ||
print(f"Loading data from {data_file}") | ||
|
||
dataMat = scipy.io.loadmat(data_file, mat_dtype=True) | ||
all_data = np.array(dataMat['features']) | ||
|
||
data = np.array(all_data[:,:len(all_data[0])-1]) | ||
labels = np.array(all_data[:,len(all_data[0])-1]) | ||
|
||
print("Data loading complete. Shape is %r" % (dataMat['features'].shape,)) | ||
|
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 load_data
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
|
||
""" | ||
Module used to load dataset of bashivan et al. 2014. | ||
""" | ||
|
||
# load data pbashivan | ||
data, labels = load_data(data_dir + "FeatureMat_timeWin.mat") | ||
data, labels = load_data(f"{data_dir}FeatureMat_timeWin.mat") | ||
print("Original data:",data.shape, labels.shape) | ||
|
||
if generate_images: | ||
|
||
# NOTE: Only a 3D projection is proporcionated, then it is not avaliable other | ||
# records with positions. | ||
|
||
#Load locations in 3D | ||
locs_orig = scipy.io.loadmat(data_dir+'Neuroscan_locs_orig.mat', mat_dtype=True) | ||
locs_orig = scipy.io.loadmat( | ||
f'{data_dir}Neuroscan_locs_orig.mat', mat_dtype=True | ||
) | ||
locs3D = locs_orig['A'] | ||
|
||
#Convert to 2D | ||
locs2D =[] | ||
for e in locs3D: | ||
locs2D.append(azim_proj(e)) | ||
|
||
|
||
locs2D = [azim_proj(e) for e in locs3D] | ||
#save in numpy array | ||
locs2D = np.array(locs2D) | ||
|
||
# visualize projection | ||
if visualize: | ||
print("No. channels:",locs3D.shape) | ||
|
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 load_bashivan_data
refactored with the following changes:
- Use f-string instead of string concatenation [×5] (
use-fstring-for-concatenation
) - Convert for loop into list comprehension (
list-comprehension
)
This removes the following comments ( why? ):
#Convert to 2D
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
for i, (train_index, test_index) in enumerate(skf.split(x, y)): | ||
|
||
for train_index, test_index in skf.split(x, y): |
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 kfcv
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
) - Replace unused for index with underscore (
for-index-underscore
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Replace unused for index with underscore (
for-index-underscore
) - Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1, 2 are executed | ||
if foldNum + 1 >= 3:# and foldNum + 1 <= 11: | ||
if foldNum >= 2:# and foldNum + 1 <= 11: |
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Hoist statements out of for/while loops (
hoist-statement-from-loop
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1, 2 are executed | ||
if foldNum + 1 >= 3:# and foldNum + 1 <= 11: | ||
continue | ||
|
||
if foldNum >= 2:# and foldNum + 1 <= 11: | ||
continue | ||
|
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Hoist statements out of for/while loops (
hoist-statement-from-loop
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
This removes the following comments ( why? ):
# Only Subjects 1, 2 are executed
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1, 2 are executed | ||
if foldNum + 1 >= 3:# and foldNum + 1 <= 11: | ||
if foldNum >= 2:# and foldNum + 1 <= 11: |
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Hoist statements out of for/while loops (
hoist-statement-from-loop
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1, 2 are executed | ||
if foldNum + 1 >= 3:# and foldNum + 1 <= 11: | ||
continue | ||
|
||
if foldNum >= 2:# and foldNum + 1 <= 11: | ||
continue | ||
|
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Hoist statements out of for/while loops (
hoist-statement-from-loop
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
This removes the following comments ( why? ):
# Only Subjects 1, 2 are executed
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1, 2 are executed | ||
if foldNum + 1 >= 3:# and foldNum + 1 <= 11: | ||
if foldNum >= 2:# and foldNum + 1 <= 11: |
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1 and 2 are executed | ||
if foldNum+1 >= 2:# and foldNum+1 <= 11: | ||
if foldNum >= 1:# and foldNum+1 <= 11: |
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Hoist statements out of for/while loops (
hoist-statement-from-loop
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
if foldNum+1 >= 3:# and foldNum+1 <= 11: | ||
if foldNum >= 2:# and foldNum+1 <= 11: |
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
out = self.fc_out(x) | ||
|
||
return out | ||
return self.fc_out(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 Predictor.forward
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1, 2 are executed | ||
if foldNum + 1 >= 3:# and foldNum + 1 <= 11: | ||
if foldNum >= 2:# and foldNum + 1 <= 11: |
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
|
||
# Extract pairs between indexes and subjects | ||
fold_pairs = get_subject_indices(subjects) | ||
|
||
# Iterate over fold_pairs | ||
for foldNum, fold in enumerate(fold_pairs): | ||
print('Beginning fold {0} out of {1}'.format(foldNum+1, len(fold_pairs))) | ||
|
||
# Only Subjects 1 and 2 are executed | ||
if foldNum+1 >= 2:# and foldNum+1 <= 11: | ||
if foldNum >= 1:# and foldNum+1 <= 11: |
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 losocv
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
) - Hoist statements out of for/while loops (
hoist-statement-from-loop
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
for batch_idx, data in enumerate(test_loader): | ||
for data in test_loader: |
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 test
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
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
develop
branch, then run: