def intersections(self) : l = self.get_list_vals() sort_list_val = self.sort_list_vals() layer,stack = {},{} cpt = 0 for i in sort_list_val : val,tag = l[i] if(tag == self.label_start) : cpt += 1 if(stack.has_key(cpt) == False or (stack.has_key(cpt) and stack[cpt] == None)) : stack[cpt] = val else : tm.dict_append(layer, cpt, (stack[cpt], val)) stack[cpt] = None cpt -= 1 return layer
#!/usr/bin/env python # -*- coding: utf-8 -*- import tool_misc as tm l = [0,2,3,2,1,5,2,4] l_pop = tm.pop_val(l,2) print 'l :: ', l print 'l_pop :: ', l_pop print d = {'k1': [0,1], 'k2':['a','b'], 'k3':[]} print 'd :: ', d tm.dict_append(d,'k1', 2) tm.dict_append(d,'k4', 'w1') print 'd :: ', d print dr = tm.drange(0,2,0.25) print 'dr :: ', dr l_inter = [(v,v+0.5) for v in dr] print 'l_inter :: ', l_inter print val_search = 0.77 i = tm.dicho_find_inter(l_inter, val_search) print 'i :: ', i print 'l_inter[i] :: ', l_inter[i] val_search = 0.75 j = tm.dicho_find(dr, val_search) print 'j :: ', j