Skip to content

Commit a93016a

Browse files
authored
Merge branch 'main' into total_memory
2 parents f375efc + 0bffc1e commit a93016a

4 files changed

Lines changed: 33 additions & 10 deletions

File tree

.github/workflows/all-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
python-version: ["3.9", "3.13"] # Lower and higher versions we support
26+
python-version: ["3.9", "3.13.3"] # Lower and higher versions we support, bug in 3.13.4 adjust when fixed
2727
os: [macos-latest, windows-latest, ubuntu-latest]
2828
steps:
2929
- uses: actions/checkout@v4

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
]
88
description = "Python toolkit for analysis, visualization, and comparison of spike sorting output"
99
readme = "README.md"
10-
requires-python = ">=3.9,<3.14"
10+
requires-python = ">=3.9,<3.13.4" # limit until Windows bug is fixed.
1111
classifiers = [
1212
"Programming Language :: Python :: 3 :: Only",
1313
"License :: OSI Approved :: MIT License",

src/spikeinterface/benchmark/benchmark_plot_tools.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ def plot_performances_vs_snr(
432432
levels_to_keep=None,
433433
orientation="vertical",
434434
show_legend=True,
435+
with_sigmoid_fit=True,
436+
show_average_by_bin=False,
435437
axs=None,
436438
):
437439
"""
@@ -455,6 +457,10 @@ def plot_performances_vs_snr(
455457
The orientation of the plot.
456458
show_legend : bool, default True
457459
Show legend or not
460+
show_sigmoid_fit : bool, default True
461+
Show sigmoid that fit the performances.
462+
show_average_by_bin : bool, default False
463+
Instead of the sigmoid an average by bins can be plotted.
458464
axs : matplotlib.axes.Axes | None, default: None
459465
The axs to use for plotting. Should be the same size as len(performance_names).
460466
@@ -478,7 +484,12 @@ def plot_performances_vs_snr(
478484
raise ValueError("orientation must be 'vertical' or 'horizontal'")
479485

480486
if axs is None:
481-
fig, axs = plt.subplots(ncols=ncols, nrows=nrows, figsize=figsize, squeeze=True)
487+
fig, axs = plt.subplots(ncols=ncols, nrows=nrows, figsize=figsize, squeeze=False)
488+
if orientation == "vertical":
489+
axs = axs[:, 0]
490+
else:
491+
axs = axs[0, :]
492+
482493
else:
483494
assert len(axs) == len(performance_names), "axs should have the same number of axes as performance_names"
484495
fig = axs[0].get_figure()
@@ -512,8 +523,12 @@ def plot_performances_vs_snr(
512523
analyzer = study.get_sorting_analyzer(dataset_key=snr_dataset_reference)
513524

514525
quality_metrics = analyzer.get_extension("quality_metrics").get_data()
515-
x = quality_metrics["snr"].values
516-
y = study.get_result(sub_key)["gt_comparison"].get_performance()[performance_name].values
526+
x = quality_metrics["snr"].to_numpy(dtype="float64")
527+
y = (
528+
study.get_result(sub_key)["gt_comparison"]
529+
.get_performance()[performance_name]
530+
.to_numpy(dtype="float64")
531+
)
517532
all_xs.append(x)
518533
all_ys.append(y)
519534

@@ -524,9 +539,17 @@ def plot_performances_vs_snr(
524539
ax.scatter(all_xs, all_ys, marker=".", label=label, color=color)
525540
ax.set_ylabel(performance_name)
526541

527-
popt = fit_sigmoid(all_xs, all_ys, p0=None)
528-
xfit = np.linspace(0, max(x), 100)
529-
ax.plot(xfit, sigmoid(xfit, *popt), color=color)
542+
if with_sigmoid_fit:
543+
popt = fit_sigmoid(all_xs, all_ys, p0=None)
544+
xfit = np.linspace(0, max(x), 100)
545+
ax.plot(xfit, sigmoid(xfit, *popt), color=color)
546+
547+
if show_average_by_bin:
548+
from scipy.stats import binned_statistic
549+
550+
bins = np.linspace(np.min(all_xs), np.max(all_xs), 20)
551+
average, bins, count = binned_statistic(all_xs, all_ys, statistic="mean", bins=bins)
552+
ax.plot(bins[:-1] + (bins[1] - bins[0]) / 2.0, average, color=color)
530553

531554
ax.set_ylim(-0.05, 1.05)
532555

src/spikeinterface/sorters/tests/test_launcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ def test_run_sorter_jobs_slurm_kwargs(mocker, tmp_path, job_list):
193193
engine="slurm",
194194
engine_kwargs=None,
195195
)
196-
tmp_script_folder = "_".join(tempfile.mkdtemp(prefix="spikeinterface_slurm_").split("_")[:-1])
197-
assert tmp_script_folder in mock_subprocess_run.call_args_list[-1].args[0][5]
196+
tmp_script_folder = Path(tempfile.gettempdir()) / "spikeinterface_slurm_"
197+
assert str(tmp_script_folder) in mock_subprocess_run.call_args_list[-1].args[0][5]
198198

199199

200200
def test_run_sorter_by_property(create_cache_folder):

0 commit comments

Comments
 (0)