|
| 1 | +import os |
| 2 | +import shutil |
| 3 | + |
| 4 | +import pytest |
| 5 | + |
| 6 | +import spikeinterface.extractors as se |
| 7 | +import spikeinterface.sorters as ss |
| 8 | + |
| 9 | +os.environ['SINGULARITY_DISABLE_CACHE'] = 'true' |
| 10 | + |
| 11 | + |
| 12 | +@pytest.fixture(autouse=True) |
| 13 | +def work_dir(request, tmp_path): |
| 14 | + """ |
| 15 | + This fixture, along with "run_kwargs" creates one folder per |
| 16 | + test function using built-in tmp_path pytest fixture |
| 17 | +
|
| 18 | + The tmp_path will be the working directory for the test function |
| 19 | +
|
| 20 | + At the end of the each test function, a clean up will be done |
| 21 | + """ |
| 22 | + os.chdir(tmp_path) |
| 23 | + yield |
| 24 | + os.chdir(request.config.invocation_dir) |
| 25 | + shutil.rmtree(str(tmp_path)) |
| 26 | + |
| 27 | + |
| 28 | +@pytest.fixture |
| 29 | +def run_kwargs(work_dir): |
| 30 | + test_recording, _ = se.toy_example( |
| 31 | + duration=30, |
| 32 | + seed=0, |
| 33 | + num_channels=64, |
| 34 | + num_segments=1 |
| 35 | + ) |
| 36 | + test_recording = test_recording.save(name='toy') |
| 37 | + return dict(recording=test_recording, verbose=True, singularity_image=True) |
| 38 | + |
| 39 | + |
| 40 | +def test_kilosort2(run_kwargs): |
| 41 | + sorting = ss.run_kilosort2(output_folder="kilosort2", **run_kwargs) |
| 42 | + print(sorting) |
| 43 | + |
| 44 | + |
| 45 | +def test_kilosort2_5(run_kwargs): |
| 46 | + sorting = ss.run_kilosort2_5(output_folder="kilosort2_5", **run_kwargs) |
| 47 | + print(sorting) |
| 48 | + |
| 49 | + |
| 50 | +def test_kilosort3(run_kwargs): |
| 51 | + sorting = ss.run_kilosort3(output_folder="kilosort3", **run_kwargs) |
| 52 | + print(sorting) |
| 53 | + |
| 54 | + |
| 55 | +@pytest.mark.skip(reason="Need to check errors") |
| 56 | +def test_pykilosort(run_kwargs): |
| 57 | + sorting = ss.run_pykilosort(output_folder="pykilosort", **run_kwargs) |
| 58 | + print(sorting) |
0 commit comments