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

restored previous tests behavior #3

Merged
merged 2 commits into from
Sep 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 38 additions & 20 deletions test/unit_tests/test_eegneuralnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
return torch.rand(3, 10), item % 4


class MockModule(EEGModuleMixin, torch.nn.Module):
class MockModule1(EEGModuleMixin, torch.nn.Module):
PierreGtch marked this conversation as resolved.
Show resolved Hide resolved
def __init__(
self,
preds,
Expand All @@ -46,7 +46,30 @@
input_window_seconds=input_window_seconds,
sfreq=sfreq,
)
# self.preds = to_tensor(preds, device='cpu')
self.preds = to_tensor(preds, device='cpu')
self.final_layer = torch.nn.Conv1d(self.n_chans, self.n_outputs, self.n_times)

def forward(self, x):
return self.preds

class MockModule2(EEGModuleMixin, torch.nn.Module):

Check failure on line 55 in test/unit_tests/test_eegneuralnet.py

View workflow job for this annotation

GitHub Actions / Flake8-Codestyle-Check

expected 2 blank lines, found 1
PierreGtch marked this conversation as resolved.
Show resolved Hide resolved
def __init__(
self,
n_outputs=None,
n_chans=None,
chs_info=None,
n_times=None,
input_window_seconds=None,
sfreq=None,
):
super().__init__(
n_outputs=n_outputs,
n_chans=n_chans,
chs_info=chs_info,
n_times=n_times,
input_window_seconds=input_window_seconds,
sfreq=sfreq,
)
self.final_layer = torch.nn.Conv1d(self.n_chans, self.n_outputs, self.n_times)

def forward(self, x):
PierreGtch marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -138,15 +161,16 @@
[0.125, 0.875],
[1., 0.],
[0.8, 0.2],
[0.8, 0.2],
[0.9, 0.1],
]
)
eegneuralnet = eegneuralnet_cls(
MockModule,
MockModule1,
module__preds=preds,
module__n_outputs=2,
module__n_chans=3,
module__n_times=3,
module__n_times=10,
optimizer=optim.Adam,
batch_size=32
)
Expand All @@ -158,7 +182,7 @@

def test_cropped_predict_and_predict_proba(eegneuralnet_cls, preds):
eegneuralnet = eegneuralnet_cls(
MockModule,
MockModule1,
module__preds=preds,
module__n_outputs=4,
module__n_chans=3,
Expand All @@ -180,7 +204,7 @@

def test_cropped_predict_and_predict_proba_not_aggregate_predictions(eegneuralnet_cls, preds):
eegneuralnet = eegneuralnet_cls(
MockModule,
MockModule1,
module__preds=preds,
module__n_outputs=4,
module__n_chans=3,
Expand All @@ -200,7 +224,7 @@

def test_predict_trials(eegneuralnet_cls, preds):
eegneuralnet = eegneuralnet_cls(
MockModule,
MockModule1,
module__preds=preds,
module__n_outputs=4,
module__n_chans=3,
Expand All @@ -219,7 +243,7 @@

def test_clonable(eegneuralnet_cls, preds):
eegneuralnet = eegneuralnet_cls(
MockModule,
MockModule1,
module__preds=preds,
module__n_outputs=4,
module__n_chans=3,
Expand All @@ -241,8 +265,7 @@
def test_set_signal_params_numpy(eegneuralnet_cls, preds, Xy):
X, y = Xy
net = eegneuralnet_cls(
MockModule,
module__preds=preds,
MockModule2,
cropped=False,
optimizer=optim.Adam,
batch_size=32,
Expand All @@ -262,9 +285,8 @@
def test_set_signal_params_torch_ds(eegneuralnet_cls, preds):
n_outputs = (1 if eegneuralnet_cls == EEGRegressor else 4)
net = eegneuralnet_cls(
MockModule,
MockModule2,
module__n_outputs=n_outputs,
module__preds=preds,
cropped=False,
optimizer=optim.Adam,
batch_size=32,
Expand All @@ -280,8 +302,7 @@
def test_set_signal_params_windows_ds_metadata(eegneuralnet_cls, preds, windows_dataset_metadata):
n_outputs = (1 if eegneuralnet_cls == EEGRegressor else 4)
net = eegneuralnet_cls(
MockModule,
module__preds=preds,
MockModule2,
cropped=False,
optimizer=optim.Adam,
batch_size=32,
Expand All @@ -297,8 +318,7 @@
def test_set_signal_params_windows_ds_channels(eegneuralnet_cls, preds, windows_dataset_channels):
n_outputs = (1 if eegneuralnet_cls == EEGRegressor else 4)
net = eegneuralnet_cls(
MockModule,
module__preds=preds,
MockModule2,
module__n_outputs=n_outputs,
cropped=False,
optimizer=optim.Adam,
Expand All @@ -315,8 +335,7 @@
def test_set_signal_params_concat_ds_metadata(eegneuralnet_cls, preds, concat_dataset_metadata):
n_outputs = (1 if eegneuralnet_cls == EEGRegressor else 4)
net = eegneuralnet_cls(
MockModule,
module__preds=preds,
MockModule2,
cropped=False,
optimizer=optim.Adam,
batch_size=32,
Expand All @@ -332,8 +351,7 @@
def test_set_signal_params_concat_ds_channels(eegneuralnet_cls, preds, concat_dataset_channels):
n_outputs = (1 if eegneuralnet_cls == EEGRegressor else 4)
net = eegneuralnet_cls(
MockModule,
module__preds=preds,
MockModule2,
module__n_outputs=n_outputs,
cropped=False,
optimizer=optim.Adam,
Expand Down