aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.py
diff options
context:
space:
mode:
authorBrian Jordan2012-04-26 01:23:32 -0400
committerBrian Jordan2012-04-26 01:23:32 -0400
commit3a5c1b91af4dde0e7270d21aca356133e5f4d8d0 (patch)
treee1aa04d9388d43d595f6c4e9cbc8fee7450f4ad1 /src/utils.py
parent0553e3ffa31633ec8b5c42fc5dbacb8b3b3bf448 (diff)
downloadvideo-tuneup-stewardess-3a5c1b91af4dde0e7270d21aca356133e5f4d8d0.tar.bz2
add earworm, outline of stewardess.rb approach
Diffstat (limited to 'src/utils.py')
-rw-r--r--src/utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/utils.py b/src/utils.py
new file mode 100644
index 0000000..3ce2048
--- /dev/null
+++ b/src/utils.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+utils.py
+
+Created by Jason Sundram, on 2010-04-05.
+"""
+
+def flatten(l):
+ """ Converts a list of tuples to a flat list.
+ e.g. flatten([(1,2), (3,4)]) => [1,2,3,4]
+ """
+ return [item for pair in l for item in pair]
+
+def tuples(l, n=2):
+ """ returns n-tuples from l.
+ e.g. tuples(range(4), n=2) -> [(0, 1), (1, 2), (2, 3)]
+ """
+ return zip(*[l[i:] for i in range(n)])
+
+def rows(m):
+ """returns the # of rows in a numpy matrix"""
+ return m.shape[0] \ No newline at end of file