def load_period_data(self, period): if self.lag_fields: self.array_lag = np.empty(len(self.array), dtype=np.dtype(self.lag_fields)) for field, _ in self.lag_fields: self.array_lag[field] = self.array[field] rows = self.input_rows.get(period) if rows is None: # nothing needs to be done in that case return start, stop = rows # It would be nice to use ColumnArray.from_table and adapt mergeArrays # to produce a ColumnArray in all cases, but it is not a huge priority # for now input_array = self.input_table.read(start, stop) self.array, self.id_to_rownum = \ mergeArrays(self.array, input_array, result_fields='array1') # this can happen, depending on the layout of columns in input_array, # but the usual case (in retro) is that self.array is a superset of # input_array, in which case mergeArrays returns a ColumnArray if not isinstance(self.array, ColumnArray): self.array = ColumnArray(self.array)
def load_period_data(self, period): rows = self.input_rows.get(period) if rows is None: # nothing needs to be done in that case return start, stop = rows input_array = self.input_table.read(start, stop) self.array, self.id_to_rownum = \ mergeArrays(self.array, input_array, result_fields='array1')
def load_period_data(self, period): if self.lag_fields: self.array_lag = np.empty(len(self.array), dtype=np.dtype(self.lag_fields)) for field, _ in self.lag_fields: self.array_lag[field] = self.array[field] rows = self.input_rows.get(period) if rows is None: # nothing needs to be done in that case return start, stop = rows input_array = self.input_table.read(start, stop) self.array, self.id_to_rownum = \ mergeArrays(self.array, input_array, result_fields='array1')
def merge_period(period_idx, period): if ent_name in ent_names1: start, stop = input1_rows.get(period, (0, 0)) input1_array = table1.read(start, stop) else: input1_array = None if ent_name in ent_names2: start, stop = input2_rows.get(period, (0, 0)) input2_array = table2.read(start, stop) else: input2_array = None if ent_name in ent_names1 and ent_name in ent_names2: output_array, _ = mergeArrays(input1_array, input2_array) elif ent_name in ent_names1: output_array = input1_array elif ent_name in ent_names2: output_array = input2_array else: raise Exception("this shouldn't have happened") output_table.append(output_array) output_table.flush()