Skip to content

Instantly share code, notes, and snippets.

View kamanazan's full-sized avatar

Muhammad Fauzan Rosyadi kamanazan

View GitHub Profile
from collections import defaultdict
def gen_dict(a):
d = defaultdict(list)
# the score would be look like this [('image_name', response_time)...]
# Group the list by image_name and combine the score
for k,v in a:
d[k].append(v)
# Output: defaultdict(<type 'list'>, {'a': [1, 2, 3], 'c': [1, 2, 3], 'b': [1, 2, 3]})
# >>> d['a']
# [1, 2, 3]
@kamanazan
kamanazan / aat_evita.py
Created March 8, 2018 10:56
image abstraction
from pathlib2 import PurePath
img_root = Path('AAT_images')
class AatImage():
def __init__(curr_path):
"""
get list of image in current directory
curr_path: PosixPAth object parent dir of the images, starts with push* / pull*
"""
self.action = 'Push' if curr_path.name.count('Push') else 'Pull'