diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-02-05 17:20:46 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-02-05 17:20:46 +0100 |
commit | 2a70358c166f32ea18fdfb20853b6242414dfc4a (patch) | |
tree | 87554aaa97d2222c0b57d11ee55363b2f079d98f /lib | |
parent | 8a5131f873d88d34644b0c29e56c229d257fa644 (diff) |
move flatten to utils
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/plotter.py | 9 | ||||
-rw-r--r-- | lib/utils.py | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/plotter.py b/lib/plotter.py index 8a28f4c..e4c7701 100755 --- a/lib/plotter.py +++ b/lib/plotter.py @@ -5,14 +5,7 @@ import numpy as np import matplotlib.pyplot as plt import re from matplotlib.patches import Polygon - -def flatten(somelist): - """ - Flatten a list. - - Example: flatten([[1, 2], [3], [4, 5]]) -> [1, 2, 3, 4, 5] - """ - return [item for sublist in somelist for item in sublist] +from utils import flatten def is_state(aggregate, name): """Return true if name is a state and not UNINITIALIZED.""" diff --git a/lib/utils.py b/lib/utils.py index 4208c3a..2cf31be 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -21,6 +21,14 @@ def float_or_nan(n): except ValueError: return np.nan +def flatten(somelist): + """ + Flatten a list. + + Example: flatten([[1, 2], [3], [4, 5]]) -> [1, 2, 3, 4, 5] + """ + return [item for sublist in somelist for item in sublist] + def param_slice_eq(a, b, index): """ Check if by_param keys a and b are identical, ignoring the parameter at index. |