From 35d16c9f4443f8ee3c3f205f76f83f6d88a989f5 Mon Sep 17 00:00:00 2001 From: ilkilic Date: Mon, 9 Oct 2023 11:51:57 +0200 Subject: [PATCH] Force evaluation for built-in map() --- bluepyefe/plotting.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bluepyefe/plotting.py b/bluepyefe/plotting.py index 516fbf0..575710e 100644 --- a/bluepyefe/plotting.py +++ b/bluepyefe/plotting.py @@ -116,6 +116,12 @@ def _plot(cell, output_dir, show=False): def plot_all_recordings(cells, output_dir, show=False, mapper=map): """Plot recordings for all cells and all protocols""" mapper(partial(_plot, output_dir=output_dir, show=show), cells) + if mapper == map: + # For the built-in map(), ensure immediate evaluation as it returns a lazy iterator + # which won't execute the function until iterated over. Converting to a list forces this iteration. + list(mapper(partial(_plot, output_dir=output_dir, show=show), cells)) + else: + mapper(partial(_plot, output_dir=output_dir, show=show), cells) def plot_efeature(