Skip to content

Commit

Permalink
TST, API: test case where edfapi C library not installed (#12)
Browse files Browse the repository at this point in the history
* DOC: Update install and usage docs

* MAINT: rename read_edf.py module to read.py

This is so that we don't confused the read_edf.py module with the read_edf function that
is part of the read_edf.py module.

The documented public API was and remains `from eyelinkio import read_edf` , which imports the function,
so this should not have any compat issues with existing user code, unless they explicitly are doing something
like eyelinkio.edf.read_edf.some_function

* TST: add test for properly catching case where edfapi is not installed

* DOC: reflect updated API

* FIX: flakes

* FIX: remove cruft....
  • Loading branch information
scott-huberty authored Dec 27, 2024
1 parent 7f5e2e5 commit c3afb9a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ for class names.
Reading EDF files
-----------------

.. automodule:: eyelinkio.edf.read_edf
.. automodule:: eyelinkio.edf.read
:members:
:exclude-members: EDF

Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Example Usage
Reading an EDF file
~~~~~~~~~~~~~~~~~~~

You can read EyeLink EDF files using the :func:`~eyelinkio.edf.read_edf` function, which
You can read EyeLink EDF files using the :func:`~eyelinkio.edf.read.read_edf` function, which
returns an :class:`~eyelinkio.EDF` instance.

.. code:: python
Expand Down
2 changes: 1 addition & 1 deletion src/eyelinkio/edf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# License: BSD (3-clause)
from .read_edf import read_edf, EDF
from .read import read_edf, EDF
File renamed without changes.
8 changes: 8 additions & 0 deletions src/eyelinkio/tests/test_edf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

import numpy as np
import pytest

Expand Down Expand Up @@ -163,3 +165,9 @@ def test_to_mne():
np.testing.assert_equal(raw.ch_names, want_chs)
else:
raise ValueError(f"Unexpected file: {fname}")

def test_edfapi_not_installed():
"""Test that an error is raised if SR Research's edfapi is not installed."""
with patch("eyelinkio.edf.read.has_edfapi", False):
with pytest.raises(OSError, match="Could not load EDF api"):
read_edf(fnames[0])
2 changes: 1 addition & 1 deletion src/eyelinkio/utils/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def _has_edfapi():
"""Determine if a user has edfapi installed."""
from ..edf.read_edf import has_edfapi
from ..edf.read import has_edfapi
return has_edfapi


Expand Down

0 comments on commit c3afb9a

Please sign in to comment.