|
| 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_spykingcircus(run_kwargs): |
| 41 | + sorting = ss.run_spykingcircus(output_folder="spykingcircus", **run_kwargs) |
| 42 | + print(sorting) |
| 43 | + |
| 44 | + |
| 45 | +def test_mountainsort4(run_kwargs): |
| 46 | + sorting = ss.run_mountainsort4(output_folder="mountainsort4", **run_kwargs) |
| 47 | + print(sorting) |
| 48 | + |
| 49 | + |
| 50 | +def test_tridesclous(run_kwargs): |
| 51 | + sorting = ss.run_tridesclous(output_folder="tridesclous", **run_kwargs) |
| 52 | + print(sorting) |
| 53 | + |
| 54 | + |
| 55 | +def test_klusta(run_kwargs): |
| 56 | + sorting = ss.run_klusta(output_folder="klusta", **run_kwargs) |
| 57 | + print(sorting) |
| 58 | + |
| 59 | + |
| 60 | +def test_ironclust(run_kwargs): |
| 61 | + sorting = ss.run_ironclust(output_folder="ironclust", fGpu=False, **run_kwargs) |
| 62 | + print(sorting) |
| 63 | + |
| 64 | + |
| 65 | +def test_waveclus(run_kwargs): |
| 66 | + sorting = ss.run_waveclus(output_folder="waveclus", **run_kwargs) |
| 67 | + print(sorting) |
| 68 | + |
| 69 | + |
| 70 | +def test_hdsort(run_kwargs): |
| 71 | + sorting = ss.run_hdsort(output_folder="hdsort", **run_kwargs) |
| 72 | + print(sorting) |
| 73 | + |
| 74 | + |
| 75 | +def test_kilosort1(run_kwargs): |
| 76 | + sorting = ss.run_kilosort(output_folder="kilosort", useGPU=False, **run_kwargs) |
| 77 | + print(sorting) |
| 78 | + |
| 79 | + |
| 80 | +@pytest.mark.skip(reason="GPU required") |
| 81 | +def test_kilosort2(run_kwargs): |
| 82 | + sorting = ss.run_kilosort2(output_folder="kilosort2", **run_kwargs) |
| 83 | + print(sorting) |
| 84 | + |
| 85 | + |
| 86 | +@pytest.mark.skip(reason="GPU required") |
| 87 | +def test_kilosort2_5(run_kwargs): |
| 88 | + sorting = ss.run_kilosort2_5(output_folder="kilosort2_5", **run_kwargs) |
| 89 | + print(sorting) |
| 90 | + |
| 91 | + |
| 92 | +@pytest.mark.skip(reason="GPU required") |
| 93 | +def test_kilosort3(run_kwargs): |
| 94 | + sorting = ss.run_kilosort3(output_folder="kilosort3", **run_kwargs) |
| 95 | + print(sorting) |
| 96 | + |
| 97 | + |
| 98 | +@pytest.mark.skip(reason="GPU required") |
| 99 | +def test_pykilosort(run_kwargs): |
| 100 | + sorting = ss.run_pykilosort(output_folder="pykilosort", **run_kwargs) |
| 101 | + print(sorting) |
0 commit comments