def read_mapping(self, group: zarr.Group) -> dict: res_dict = {} if 'scalar' in group.attrs: res_dict.update(group.attrs['scalar']) for key in group.array_keys(): res_dict[key] = self.read_array(group, key) for key in group.group_keys(): sub_group = group[key] data_type = sub_group.attrs['data_type'] value = None if data_type == 'data_frame' or data_type == 'record_array': value = self.read_dataframe(sub_group) elif data_type == 'csr_matrix': value = self.read_csr(sub_group) else: assert data_type == 'dict' value = self.read_mapping(sub_group) res_dict[key] = value return res_dict
def read_array(self, group: zarr.Group, name: str) -> Union[np.ndarray, np.recarray]: if name in group.group_keys(): return self.read_dataframe(group[name]) else: return group[name][...]