Repository: aeye-lab/pymovements
Pull request #811 (2024-09-26 11:18:55)

fix stimulus text wrong handling of missing values

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/aeye-lab/pymovements/pull/811?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 99.93%. Comparing base [(`7c28ef0`)](https://app.codecov.io/gh/aeye-lab/pymovements/commit/7c28ef0664ae6ded2e5f8043410983e5a6b8df35?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aeye-lab) to head [(`63840c2`)](https://app.codecov.io/gh/aeye-lab/pymovements/commit/63840c29157c741a1d26fd4cc22e2001dee5fe08?dropdown=coverage&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     #811      +/-   ##
===========================================
- Coverage   100.00%   99.93%   -0.07%     
===========================================
  Files           71       71              
  Lines         3227     3228       +1     
  Branches       925      859      -66     
===========================================
- Hits          3227     3226       -1     
- Misses           0        1       +1     
- Partials         0        1       +1     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/aeye-lab/pymovements/pull/811?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/stimulus/text.py b/src/pymovements/stimulus/text.py
index cd404c6..6e91570 100644
--- a/src/pymovements/stimulus/text.py
+++ b/src/pymovements/stimulus/text.py
@@ -116,6 +116,7 @@ def from_file(
             aoi_path,
             **custom_read_kwargs,
         )
+        stimulus_df = stimulus_df.fill_null(' ')
     else:
         raise ValueError(
             f'unsupported file format "{aoi_path.suffix}".'


Test patch:
diff --git a/tests/unit/events/event_aoi_mapping_test.py b/tests/unit/events/event_aoi_mapping_test.py
index e246aca..775435e 100644
--- a/tests/unit/events/event_aoi_mapping_test.py
+++ b/tests/unit/events/event_aoi_mapping_test.py
@@ -93,7 +93,7 @@ EXPECTED_DF = {
             (0, 1, 'fixation', 2002863, 2003003, 140, 161.3858184814453, 482.514892578125, ''),
             (0, 1, 'fixation', 2003042, 2003424, 382, 211.2224578857422, 483.4208984375, ''),
             (0, 1, 'fixation', 2003453, 2003657, 204, 283.94683837890625, 485.6600036621094, ''),
-            (0, 1, 'fixation', 2003721, 2003917, 196, 422.4142150878906, 484.2720947265625, None),
+            (0, 1, 'fixation', 2003721, 2003917, 196, 422.4142150878906, 484.2720947265625, ' '),
             (0, 1, 'fixation', 2003968, 2004074, 106, 509.65234375, 480.1925354003906, 'n'),
             (0, 1, 'fixation', 2004132, 2004331, 199, 610.8610229492188, 484.6025085449219, 'g'),
             (0, 1, 'fixation', 2004399, 2004687, 288, 717.8470458984375, 486.0269775390625, ''),
@@ -194,7 +194,7 @@ EXPECTED_DF = {
             (0, 1, 'fixation', 2002863, 2003003, 140, 161.3858184814453, 482.514892578125, ''),
             (0, 1, 'fixation', 2003042, 2003424, 382, 211.2224578857422, 483.4208984375, ''),
             (0, 1, 'fixation', 2003453, 2003657, 204, 283.94683837890625, 485.6600036621094, ''),
-            (0, 1, 'fixation', 2003721, 2003917, 196, 422.4142150878906, 484.2720947265625, None),
+            (0, 1, 'fixation', 2003721, 2003917, 196, 422.4142150878906, 484.2720947265625, ' '),
             (0, 1, 'fixation', 2003968, 2004074, 106, 509.65234375, 480.1925354003906, 'Python'),
             (0, 1, 'fixation', 2004132, 2004331, 199, 610.8610229492188, 484.6025085449219, 'package'),  # noqa:E501
             (0, 1, 'fixation', 2004399, 2004687, 288, 717.8470458984375, 486.0269775390625, ''),
diff --git a/tests/unit/stimulus/text_test.py b/tests/unit/stimulus/text_test.py
index 0b56041..8617fa2 100644
--- a/tests/unit/stimulus/text_test.py
+++ b/tests/unit/stimulus/text_test.py
@@ -34,10 +34,10 @@ EXPECTED_DF = polars.DataFrame(
             'h',
             'a',
             't',
-            polars.Null,
+            ' ',
             'i',
             's',
-            polars.Null,
+            ' ',
             'p',
             'y',
             'm',
@@ -68,10 +68,10 @@ EXPECTED_DF = polars.DataFrame(
             'What',
             'What',
             'What',
-            polars.Null,
+            ' ',
             'is',
             'is',
-            polars.Null,
+            ' ',
             'pymovements?',
             'pymovements?',
             'pymovements?',