Skip to content
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 Starbot ⭐ refactored curenosm/MeIA #3

Open
wants to merge 1 commit into
base: develop
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 develop branch, then run:

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

Copy link
Author

@SourceryAI SourceryAI left a 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:
Copy link
Author

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:

for i, (train_index, test_index) in enumerate(skf.split(x, y)):

for train_index, test_index in skf.split(x, y):
Copy link
Author

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:


Copy link
Author

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:

Comment on lines -34 to +43
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,))

Copy link
Author

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:

Comment on lines -34 to +43
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,))

Copy link
Author

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:

Comment on lines -281 to +308

"""
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)

Copy link
Author

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:

This removes the following comments ( why? ):

#Convert to 2D

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

for i, (train_index, test_index) in enumerate(skf.split(x, y)):

for train_index, test_index in skf.split(x, y):
Copy link
Author

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:


Copy link
Author

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

Comment on lines -83 to +92

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

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

Comment on lines -86 to +96

# 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

Copy link
Author

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:

This removes the following comments ( why? ):

# Only Subjects 1, 2 are executed

Comment on lines -83 to +92

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

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

Comment on lines -86 to +96

# 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

Copy link
Author

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:

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

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:

Comment on lines -85 to +94

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

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

Comment on lines -85 to +94

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

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

Comment on lines -84 to +92

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

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:

out = self.fc_out(x)

return out
return self.fc_out(x)
Copy link
Author

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

Comment on lines -85 to +94

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

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

Comment on lines -85 to +94

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

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:

for batch_idx, data in enumerate(test_loader):
for data in test_loader:
Copy link
Author

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:

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