def write_errors(self, value, errors): """ // Writes Error[] T[] { varint length; T* items; } Error { varint error_label; float error_minus; float error_plus; } """ t = get_current_transaction() t.write(self.fp_records, varint_format(len(errors))) for error in errors: error_label_str = error.get('label', '') if 'asymerror' in error: error_minus = error_to_float(value, error['asymerror']['minus']) error_plus = error_to_float(value, error['asymerror']['plus']) else: error_minus = error_plus = error_to_float(value, error['symerror']) error_label = self.string_dict.id_for_str(error_label_str) t.write(self.fp_records, varint_format(error_label)) t.write(self.fp_records, struct.pack('<ff', error_minus, error_plus))
def write_group_header(self, metadata, num_records): t = get_current_transaction() t.write(self.fp_records, varint_format(metadata.inspire_record)) t.write(self.fp_records, varint_format(metadata.table_num)) t.write(self.fp_records, struct.pack('<ff', *metadata.cmenergies)) t.write(self.fp_records, string_format(metadata.reaction)) t.write(self.fp_records, string_format(metadata.observables)) t.write(self.fp_records, string_format(metadata.var_y)) t.write(self.fp_records, size_format(num_records))