예제 #1
0
파일: rest.py 프로젝트: lzlgboy/cellxgene
def annotations_put_fbs_helper(data_adaptor, annotations, fbs):
    """helper function to write annotations from fbs"""
    if annotations is None:
        raise DisabledFeatureError("Writable annotations are not enabled")

    new_label_df = decode_matrix_fbs(fbs)
    if not new_label_df.empty:
        data_adaptor.check_new_labels(new_label_df)
    annotations.write_labels(new_label_df, data_adaptor)
예제 #2
0
 def test_roundtrip(self):
     dfSrc = pd.DataFrame(
         data={
             "a": np.zeros((10,), dtype=np.float32),
             "b": np.ones((10,), dtype=np.int64),
             "c": np.array([i for i in range(0, 10)], dtype=np.uint16),
             "d": pd.Series(["x", "y", "z", "x", "y", "z", "a", "x", "y", "z"], dtype="category"),
         }
     )
     dfDst = decode_matrix_fbs(encode_matrix_fbs(matrix=dfSrc, col_idx=dfSrc.columns))
     self.assertEqual(dfSrc.shape, dfDst.shape)
     self.assertEqual(set(dfSrc.columns), set(dfDst.columns))
     for c in dfSrc.columns:
         self.assertTrue(c in dfDst.columns)
         if isinstance(dfSrc[c], pd.Series):
             self.assertTrue(np.all(dfSrc[c] == dfDst[c]))
         else:
             self.assertEqual(dfSrc[c], dfDst[c])
예제 #3
0
 def convert(mat, cols):
     return decode_matrix_fbs(encode_matrix_fbs(
         mat, col_idx=cols)).to_numpy()