From 7c1d60fb656dd8428081af015dbf340f4beeec25 Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Fri, 24 Feb 2012 16:03:14 -0800 Subject: Use dict comprehension to make it more readable --- data/svm/classification.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'data') diff --git a/data/svm/classification.py b/data/svm/classification.py index 7f4532c..26cb283 100755 --- a/data/svm/classification.py +++ b/data/svm/classification.py @@ -39,14 +39,14 @@ def normalize_filter(a,weights=None,nameset=None): a = np.ma.masked_array(a) #normalize data if weights==None: - weights = dict(zip(range(4,13),[None]*9)) + weights = {i:None for i in range(4,13)} a,weights = normalize(a,weights) if nameset != None: indexes = [i for i in range(a.shape[0]) if a[i][0] in nameset] a = a[indexes] - return list(a[:,0]),[dict(zip(range(1,11),r)) for r in a[:,4:]],weights + return list(a[:,0]),[{i:v for i,v in enumerate(row[4:])} for row in a],weights def perform_svm(a,b,nameset=None): y1,x1,weights = normalize_filter(a,nameset=nameset) -- cgit v1.2.3-70-g09d2