Changeset 1375:c0dc0956d5ef in orange-bioinformatics


Ignore:
Timestamp:
04/19/11 11:12:27 (3 years ago)
Author:
markotoplak
Branch:
default
Convert:
1b6138123535ee095e51003d10a8f79b9306a791
Message:

Fixed bug in OWGenotypeDistances.separate_by, which caused the separated tables to have different numbers of experiments if the relevant values repeated between experiments in the separated tables. Solved by using multisets instead of sets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • widgets/OWGenotypeDistances.py

    r1370 r1375  
    6565            for v in other_relevant) 
    6666 
    67     other_relevant_d = defaultdict(list) 
    68     for i,a in enumerate(annotations): 
    69         other_relevant_d[relevant_vals(a)].append(i) 
    70  
     67    other_relevant_d2 = defaultdict(int) #"multiset" - number 
     68    #of maximum occurances of a relevant value in a group 
     69    for _,g in groups.items(): 
     70        d = defaultdict(int) 
     71        for i in g: 
     72            d[relevant_vals(annotations[i])] += 1 
     73        for rv,n in d.items(): 
     74            if n > other_relevant_d2[rv]: 
     75                other_relevant_d2[rv] = n 
     76     
    7177    if add_empty: #fill in with "empty" relevant vals 
    7278        ngroups = {} 
    7379        for g in groups: 
    74             ngroups[g] = groups[g] + list(set(other_relevant_d) -  
    75                 set([ relevant_vals(annotations[e]) for e in groups[g] ])) 
     80            need_to_fill = other_relevant_d2.copy() 
     81            for i in groups[g]: 
     82                need_to_fill[relevant_vals(annotations[i])] -= 1 
     83            add = [] 
     84            for rv,num in need_to_fill.items(): 
     85                for a in range(num): 
     86                    add.append(rv) 
     87            ngroups[g] = groups[g] + add 
    7688        groups = ngroups 
    7789 
     
    504516     
    505517 
     518 
    506519if __name__ == "__main__": 
    507520    import os, sys 
Note: See TracChangeset for help on using the changeset viewer.