def load_period_data(self, period): if self.lag_fields: # TODO: use ColumnArray here # XXX: do we need np.empty? (but watch for alias problems) 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] # if not self.indexed_input_table.has_period(period): # # nothing needs to be done in that case # return # # input_array = self.indexed_input_table.read(period) 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 merge_arrays # 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 = \ merge_arrays(self.array, input_array, result_fields='array1', default_values=self.fields.default_values) # 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 merge_arrays returns a ColumnArray if not isinstance(self.array, ColumnArray): self.array = ColumnArray(self.array)
def _autodiff(self, period, showdiffs=10, raiseondiff=False): fields = self._modified_fields if not fields: return fname, numrows = config.autodiff h5file = config.autodump_file tablepath = '/p{}/{}'.format(period, self._tablename(period)) print("comparing with {}{} ...".format(fname, tablepath)) if tablepath in h5file: table = h5file.getNode(tablepath) disk_array = ColumnArray.from_table(table, stop=numrows) diff_array(disk_array, ColumnArray(fields), showdiffs, raiseondiff) else: print(" SKIPPED (could not find table)")