def find_items_release_by_public_list(self, name_list, type_): tag = Tag.objects.get(name=name_list, type=type_) if tag is None: return None itemsrel = StableDict() now = datetime.datetime.now() itemstag = Tag_Items.objects.filter(tag=tag, date_ini__lte=now).exclude(date_end__lte=now).order_by("-date_ini") for item in itemstag: date = item.date_ini if itemsrel.has_key(date): itemsrel[date].append(item.item) else: itemsrel[date] = [item.item] # al introducir los items ordenados en un hash se pierde el orden # hay que pensar otra manera de enviar los datos a la vista # new_item = {} # sorted_keys = itemsrel.keys() # sorted_keys.sort() # # for key in sorted_keys: # new_item[key] = [] # for item in itemsrel[key]: # new_item[key].append(item) return itemsrel
def find_items_release_by_public_list(self, name_list, type_): tag = Tag.objects.get(name=name_list, type=type_) if tag is None: return None itemsrel = StableDict() now = datetime.datetime.now() itemstag = Tag_Items.objects.filter(tag=tag, date_ini__lte=now).exclude(date_end__lte=now).order_by('-date_ini') for item in itemstag: date = item.date_ini if itemsrel.has_key(date): itemsrel[date].append(item.item) else: itemsrel[date] = [item.item] #al introducir los items ordenados en un hash se pierde el orden #hay que pensar otra manera de enviar los datos a la vista # new_item = {} # sorted_keys = itemsrel.keys() # sorted_keys.sort() # # for key in sorted_keys: # new_item[key] = [] # for item in itemsrel[key]: # new_item[key].append(item) return itemsrel
def load_file(filename): _register_csv_dialect() reader = csv.reader(open(filename), dialect="SimulationData") timepoints = [] measurement_list = [] for (i, row) in enumerate(reader): # we don't use the i... yet values = StableDict() for (j,value) in enumerate(row): if j == 0: # jump over the 0th row time = value # time value is always in the 0th column continue species_id = reader.fieldnames[j] values[species_id] = value timepoints.append(time) measurement_list.append(values) measurement_vector = MeasurementList(len(measurement_list)) for i, (time, values) in enumerate(measurement_list): meas_point = MeasurementPoint() for id, value in values.items(): meas_point[id] = (value, 0.0) # dummy weight of 0.0 for now measurement_vector[i] = meas_point return (timepoints, measurement_vector)