Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cebra/datasets/synthetic_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ def __init__(self, name, root=_DEFAULT_DATADIR, download=True):
self.index = self.data['u']
self.lam = self.data['lam']


def split(self, split):
tot_len = len(self.neural)
train_idx = np.arange(tot_len)[:int(tot_len*0.8)]
valid_idx = np.arange(tot_len)[int(tot_len*0.8):]
Comment on lines +118 to +119
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The hardcoded 0.8 split ratio should be extracted as a configurable parameter or class constant to improve maintainability and allow for different split ratios.

Copilot uses AI. Check for mistakes.


if split == 'train':
self.neural = self.neural[train_idx]
self.index = self.index[train_idx]
self.idx = train_idx
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method modifies the instance state by setting self.idx, but this attribute is not defined in init. This could lead to inconsistent state if split() is called multiple times or if other code expects self.idx to always exist.

Copilot uses AI. Check for mistakes.

elif split == 'valid':
self.neural = self.neural[valid_idx]
self.index = self.index[valid_idx]
self.idx = valid_idx
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method modifies the instance state by setting self.idx, but this attribute is not defined in init. This could lead to inconsistent state if split() is called multiple times or if other code expects self.idx to always exist.

Copilot uses AI. Check for mistakes.

elif split == 'all':
pass
else:
raise ValueError(f"{split} not supported")

@property
def input_dimension(self):
return self.neural.size(1)
Expand Down
Loading