summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..afd2537
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,30 @@
+
+def fl(number, precision=6):
+ formatstring = '{:.'+str(precision)+'f}'
+ return float(formatstring.format(number))
+
+
+def depth(myList, counter):
+ counter += 1
+ depthList = []
+ for item in myList:
+ if isinstance(item, list):
+ depthList.append(depth(item, counter))
+ else:
+ depthList.append(counter)
+ return depthList
+
+def flatten(pool):
+ res = []
+ for v in pool:
+ if isinstance(v, list):
+ res += flatten(v)
+ else:
+ if isinstance(v, int) or isinstance(v, str):
+ res.append(v)
+ return res
+
+def isOversliced(bars):
+ targets = [bar < 2.5 for bar in bars]
+ return (True in targets)
+