Skip to content

Commit

Permalink
from_anndata test if is_dict_like
Browse files Browse the repository at this point in the history
  • Loading branch information
bli25 committed Oct 8, 2021
1 parent c9374e8 commit 8ff99b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pegasusio/unimodal_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,12 @@ def from_anndata(self, data: anndata.AnnData, genome: str = None, modality: str
self.matrices[key] = csr_matrix(value)

def _create_data_dict(old_dict: dict) -> DataDict:
from pandas.api.types import is_dict_like
new_dict = dict()
for key, value in old_dict.items():
if str(type(value)).find("anndata") >= 0:
# This is anndata defined type
if isinstance(value, dict):
if is_dict_like(value):
new_dict[key] = dict(value)
else:
logger.warning(f"{key} is in anndata-defined data type {type(value)} and thus skipped!")
Expand Down

0 comments on commit 8ff99b9

Please sign in to comment.