Repository: aeye-lab/pymovements
Pull request #711 (2024-03-28 17:10:55)

fix: forward experiment from dataset definition to from_asc
integration test did not pass for `ToyDatasetEyeLink`, I checked why, and the experiment definition was not passed correctly. easy fix. added test.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/aeye-lab/pymovements/pull/711?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`ec93485`)](https://app.codecov.io/gh/aeye-lab/pymovements/commit/ec93485dbe1c559f34f452ccc7906bbdf19bbfd7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab) to head [(`3c65ded`)](https://app.codecov.io/gh/aeye-lab/pymovements/pull/711?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab).


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##              main      #711   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           60        60           
  Lines         2757      2757           
  Branches       709       709           
=========================================
  Hits          2757      2757           
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/aeye-lab/pymovements/pull/711?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab).


Patch:
diff --git a/src/pymovements/dataset/dataset_files.py b/src/pymovements/dataset/dataset_files.py
index c8c1872..6f86380 100644
--- a/src/pymovements/dataset/dataset_files.py
+++ b/src/pymovements/dataset/dataset_files.py
@@ -338,6 +338,7 @@ def load_gaze_file(
     elif filepath.suffix == '.asc':
         gaze_df = from_asc(
             filepath,
+            experiment=definition.experiment,
             add_columns=add_columns,
             column_dtypes=definition.filename_format_dtypes,
             **custom_read_kwargs,


Test patch:
diff --git a/tests/unit/dataset/dataset_files_test.py b/tests/unit/dataset/dataset_files_test.py
index e7f2d21..a8eeb4b 100644
--- a/tests/unit/dataset/dataset_files_test.py
+++ b/tests/unit/dataset/dataset_files_test.py
@@ -154,7 +154,10 @@ MSG	2154570 0 READING_SCREEN_1.STOP
 EXPECTED_DF_NO_PATTERNS = pl.from_dict(
     {
         'time': [2154557, 2154558, 2154560, 2154561, 2154565, 2154567, 2154568],
-        'pixel': [(139.6, 132.1), (139.5, 131.9), (None, None), (850.7, 717.5), (139.5, 131.9), (None, None), (850.7, 717.5)],
+        'pixel': [
+            (139.6, 132.1), (139.5, 131.9), (None, None), (850.7, 717.5),
+            (139.5, 131.9), (None, None), (850.7, 717.5),
+        ],
         'pupil': [784.0, 784.0, 0.0, 714.0, 784.0, 0.0, 714.0],
     },
 )
@@ -162,7 +165,10 @@ EXPECTED_DF_NO_PATTERNS = pl.from_dict(
 EXPECTED_DF_PATTERNS = pl.from_dict(
     {
         'time': [2154557, 2154558, 2154560, 2154561, 2154565, 2154567, 2154568],
-        'pixel': [(139.6, 132.1), (139.5, 131.9), (None, None), (850.7, 717.5), (139.5, 131.9), (None, None), (850.7, 717.5)],
+        'pixel': [
+            (139.6, 132.1), (139.5, 131.9), (None, None), (850.7, 717.5),
+            (139.5, 131.9), (None, None), (850.7, 717.5),
+        ],
         'pupil': [784.0, 784.0, 0.0, 714.0, 784.0, 0.0, 714.0],
         'task': ['reading', 'reading', 'reading', 'reading', 'reading', 'reading', 'reading'],
         'trial_id': [0, 0, 0, 0, 1, 1, 1],
@@ -196,10 +202,12 @@ def test_load_eyelink_file(tmp_path, read_kwargs):
     filepath = tmp_path / 'sub.asc'
     filepath.write_text(ASC_TEXT)
 
-    df = pm.dataset.dataset_files.load_gaze_file(
+    gaze = pm.dataset.dataset_files.load_gaze_file(
         filepath,
         fileinfo_row={},
-        definition=DatasetDefinition(),
+        definition=DatasetDefinition(
+            experiment=pm.Experiment(1024, 768, 38, 30, None, 'center', 100),
+        ),
         custom_read_kwargs=read_kwargs,
     )
 
@@ -208,4 +216,5 @@ def test_load_eyelink_file(tmp_path, read_kwargs):
     else:
         expected_df = EXPECTED_DF_NO_PATTERNS
 
-    assert_frame_equal(df.frame, expected_df, check_column_order=False)
+    assert_frame_equal(gaze.frame, expected_df, check_column_order=False)
+    assert gaze.experiment is not None