From e81801c4cb30248f9b8e648d0543b55666fd178c Mon Sep 17 00:00:00 2001 From: Markus Date: Thu, 17 Jan 2019 09:39:21 -0200 Subject: [PATCH] support list of mechsteps instead of dict Keeping support to dictionaries so it doesn't break existing configuration files. Issuing warning so that everyone is aware. --- SimCAD/utils/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SimCAD/utils/__init__.py b/SimCAD/utils/__init__.py index 720ab6a..8b620cc 100644 --- a/SimCAD/utils/__init__.py +++ b/SimCAD/utils/__init__.py @@ -10,8 +10,13 @@ def print_pipe(x): def flatten(l): return [item for sublist in l for item in sublist] - +import warnings def key_filter(l, keyname): + if (type(l)==list): + return [v[keyname] for v in l] + # Keeping support to dictionaries for backwards compatibility + # Should be removed in the future + warnings.warn("The use of a dictionary to describe Partial State Update Blocks will be deprecated. Use a list instead.", FutureWarning) return [v[keyname] for k, v in l.items()]