Skip to content

Commit

Permalink
fix some eye component issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrako committed Sep 14, 2023
1 parent ad80a5a commit 76c3662
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/pymovements/gaze/gaze_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,21 +646,22 @@ def _infer_eye_components(self, eye: str) -> tuple[int, int]:
elif eye == 'left':
if isinstance(self.n_components, int) and self.n_components < 4:
# Left only makes sense if there are at least two eyes.
raise AttributeError()
raise AttributeError('right eye is only supported for at least binocular data')
eye_components = 0, 1
elif eye == 'right':
if isinstance(self.n_components, int) and self.n_components < 4:
# Right only makes sense if there are at least two eyes.
raise AttributeError()
raise AttributeError('right eye is only supported for at least binocular data')
eye_components = 2, 3
elif eye == 'cyclops':
if isinstance(self.n_components, int) and self.n_components < 6:
raise AttributeError()
raise AttributeError('cyclops components are not available')
eye_components = 4, 5
elif eye == 'mono':
eye_components = 0, 1
else:
raise ValueError()
raise ValueError(
f'value {eye} for eye is not supported. '
f"Supported values are: ['auto', 'left', 'right', 'cyclops', 'mono']",
)

return eye_components

Expand Down
4 changes: 2 additions & 2 deletions tests/dataset/dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def test_detect_events_multiple_calls(
{
'method': 'microsaccades',
'threshold': 1,
'eye': 'left',
'eye': 'auto',
'clear': False,
'verbose': True,
},
Expand All @@ -771,7 +771,7 @@ def test_detect_events_alias(dataset_configuration, detect_kwargs, monkeypatch):
dataset.pos2vel()

mock = Mock()
monkeypatch.setattr(dataset, 'detect_events', mock)
monkeypatch.setattr(dataset, 'detect', mock)

dataset.detect(**detect_kwargs)
mock.assert_called_with(**detect_kwargs)
Expand Down
10 changes: 5 additions & 5 deletions tests/gaze/detect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
events=pm.EventDataFrame(name='fixation', onsets=[0], offsets=[100]),
),
pm.EventDataFrame(),
id='fixation_from_start_to_end_no_fill',
id='fill_fixation_from_start_to_end_no_fill',
),
pytest.param(
Expand All @@ -541,7 +541,7 @@
onsets=[0],
offsets=[9],
),
id='fixation_10_ms_after_start_to_end_single_fill',
id='fill_fixation_10_ms_after_start_to_end_single_fill',
),
pytest.param(
Expand All @@ -556,7 +556,7 @@
onsets=[90],
offsets=[99],
),
id='fixation_from_start_to_10_ms_before_end_single_fill',
id='fill_fixation_from_start_to_10_ms_before_end_single_fill',
),
pytest.param(
Expand All @@ -571,7 +571,7 @@
onsets=[40],
offsets=[49],
),
id='fixation_10_ms_break_at_40ms_single_fill',
id='fill_fixation_10_ms_break_at_40ms_single_fill',
),
pytest.param(
Expand All @@ -588,7 +588,7 @@
onsets=[40],
offsets=[49],
),
id='fixation_10_ms_break_then_saccade_until_end_single_fill',
id='fill_fixation_10_ms_break_then_saccade_until_end_single_fill',
),
],
)
Expand Down

0 comments on commit 76c3662

Please sign in to comment.