Exemple #1
0
 def test_matrix_to_dataframe_no_names_dataframe_sparse(self):
     Y = scprep.io.utils._matrix_to_data_frame(self.X_dense, sparse=True)
     assert scprep.utils.is_sparse_dataframe(Y)
     assert not scprep.utils.is_SparseDataFrame(Y)
     assert np.all(scprep.utils.toarray(Y) == self.X_numpy)
     utils.assert_matrix_class_equivalent(Y, self.X_sparse)
     Y = scprep.io.utils._matrix_to_data_frame(self.X_sparse, sparse=True)
     assert scprep.utils.is_sparse_dataframe(Y)
     assert not scprep.utils.is_SparseDataFrame(Y)
     assert np.all(scprep.utils.toarray(Y) == self.X_numpy)
     utils.assert_matrix_class_equivalent(Y, self.X_sparse)
Exemple #2
0
 def test_matrix_to_dataframe_names_dense(self):
     Y = scprep.io.utils._matrix_to_data_frame(
         self.X_dense,
         cell_names=self.cell_names,
         gene_names=self.gene_names,
         sparse=False,
     )
     assert isinstance(Y, pd.DataFrame)
     assert not scprep.utils.is_sparse_dataframe(Y)
     assert not scprep.utils.is_SparseDataFrame(Y)
     assert np.all(scprep.utils.toarray(Y) == self.X_numpy)
     utils.assert_matrix_class_equivalent(Y, self.X_dense)
     Y = scprep.io.utils._matrix_to_data_frame(
         self.X_sparse,
         cell_names=self.cell_names,
         gene_names=self.gene_names,
         sparse=False,
     )
     assert isinstance(Y, pd.DataFrame)
     assert not scprep.utils.is_sparse_dataframe(Y)
     assert not scprep.utils.is_SparseDataFrame(Y)
     assert np.all(scprep.utils.toarray(Y) == self.X_numpy)
     utils.assert_matrix_class_equivalent(Y, self.X_dense)
     Y = scprep.io.utils._matrix_to_data_frame(
         self.X_numpy,
         cell_names=self.cell_names,
         gene_names=self.gene_names,
         sparse=False,
     )
     assert isinstance(Y, pd.DataFrame)
     assert not scprep.utils.is_sparse_dataframe(Y)
     assert not scprep.utils.is_SparseDataFrame(Y)
     assert np.all(scprep.utils.toarray(Y) == self.X_numpy)
     utils.assert_matrix_class_equivalent(Y, self.X_dense)