Skip to content

Commit

Permalink
Add mp_context check
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Sep 23, 2024
1 parent 9ddc7ce commit 59bb1e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/spikeinterface/postprocessing/principal_component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import warnings
import platform
from pathlib import Path
from tqdm.auto import tqdm

Expand Down Expand Up @@ -418,6 +419,11 @@ def _fit_by_channel_local(self, n_jobs, progress_bar, max_threads_per_process, m

p = self.params

if mp_context is not None and platform.system() == "Windows":
assert mp_context != "fork", "'fork' mp_context not supported on Windows!"
elif mp_context == "fork" and platform.system() == "Darwin":
warnings.warn('As of Python 3.8 "fork" is no longer considered safe on macOS')

unit_ids = self.sorting_analyzer.unit_ids
channel_ids = self.sorting_analyzer.channel_ids
# there is one PCA per channel for independent fit per channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_multi_processing(self):
sorting_analyzer = self._prepare_sorting_analyzer(
format="memory", sparse=False, extension_class=ComputePrincipalComponents
)
sorting_analyzer.compute("principal_components", mode="by_channel_local", n_jobs=2, mp_context="fork")
sorting_analyzer.compute("principal_components", mode="by_channel_local", n_jobs=2)
sorting_analyzer.compute(
"principal_components", mode="by_channel_local", n_jobs=2, max_threads_per_process=4, mp_context="spawn"
)
Expand Down

0 comments on commit 59bb1e7

Please sign in to comment.