def from_array(self, data, labels):
"""Fill matrix from 2 dimensional array
Args:
data (np.array): 2 dimensional square array with scores
labels (list): List of labels for each column and row index
"""
labels = [np.string_(d) for d in labels]
self.labels = self.h5file.create_carray('/', 'labels', obj=labels, filters=self.filters)
self.h5file.flush()
self.build_label_cache()
nr_frags = len(labels)
self.scores = self.h5file.create_carray('/', 'scores', atom=tables.UInt16Atom(),
shape=(nr_frags, nr_frags), chunkshape=(1, nr_frags),
filters=self.filters)
self.scores[0:nr_frags, 0:nr_frags] = (data * self.score_precision).astype('uint16')
评论列表
文章目录