Skip to content

Commit

Permalink
add warning when input files are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Nov 27, 2023
1 parent f005136 commit d063d1f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
38 changes: 38 additions & 0 deletions CONTRTIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# How to contribute

## Install

- fork the repository
- clone your fork

```bash
git clone https://github.com/YOUR_GITHUB_USERNAME/eye2bids.git
```

- install the package in editable mode with all its development dependencies

```bash
cd eye2bids
pip install -e '.[dev]'
```

## Test


To run the tests, you need to install the [test data from OSF](https://osf.io/jdv7n/)
by running the following command:

```bash
python tools/download_test_data.py
```

You can then run any test by using pytest

```bash
python -m pytest tests/path_to_test_file.py::function_to_run
```

For example:
```bash
python -m pytest tests/test_edf2bids.py::test_convert_edf_to_asc_events
```
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,4 @@ You can build the docker image with the following command:
docker build -t eye2bids:latest .
```

## Contributing

Make sure you install eye2bids in editable mode (see above) and install the development dependencies:

```bash
pip install --editable .[dev]
```

To run the tests, you need to install the [test data from OSF](https://osf.io/jdv7n/)
by running the following command:

```bash
python tools/download_test_data.py
```

## Related projects
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from pathlib import Path
from warnings import warn

import pytest

Expand All @@ -16,13 +17,22 @@ def asc_test_files(input_dir: Path = data_dir()) -> list[Path]:
for f in files
if (not str(f).endswith("events.asc") and not str(f).endswith("samples.asc"))
]
if not tmp:
warn(
f"No .asc file found in: {input_dir}."
"Found the following .asc,"
"but they either end with 'events' or 'samples':"
f"{list(files)}"
)
return tmp


def edf_test_files(input_dir: Path = data_dir()) -> list[Path]:
files = list(input_dir.glob("**/*.edf"))
EDF_files = list(input_dir.glob("**/*.EDF"))
files.extend(EDF_files)
if not files:
warn(f"No EDF file found in: {input_dir}")
return files


Expand Down
11 changes: 9 additions & 2 deletions tests/test_edf2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def test_edf_nan_in_tsv(eyelink_test_data_dir):

@pytest.mark.skipif(not _check_edf2asc_present(), reason="edf2asc missing")
def test_number_columns_2eyes_tsv(eyelink_test_data_dir):
"""Check that values for both eyes were extracted by number of columns (function _samples_to_data_frame)"""
"""Check that values for both eyes were extracted by number of columns.
function _samples_to_data_frame
"""
input_dir = eyelink_test_data_dir / "2eyes"
input_file = edf_test_files(input_dir=input_dir)[0]

Expand All @@ -111,8 +114,12 @@ def test_number_columns_2eyes_tsv(eyelink_test_data_dir):

@pytest.mark.skipif(not _check_edf2asc_present(), reason="edf2asc missing")
def test_number_columns_1eye_tsv(eyelink_test_data_dir):
"""Check that values for one eye were extracted by number of columns (function _samples_to_data_frame)"""
"""Check that values for one eye were extracted by number of columns.
function _samples_to_data_frame.
"""
input_dir = eyelink_test_data_dir / "rest"
print(edf_test_files(input_dir=input_dir))
input_file = edf_test_files(input_dir=input_dir)[0]

output_dir = data_dir() / "output"
Expand Down

0 comments on commit d063d1f

Please sign in to comment.