Skip to content

Commit

Permalink
Allow any mapping to be converted (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivirshup authored Aug 14, 2020
1 parent 216e16c commit 9a835b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions anndata2ri/py2r.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Mapping
from warnings import warn

import numpy as np
Expand Down Expand Up @@ -26,8 +27,8 @@ class NotConvertedWarning(Warning):
dict_converter.py2rpy.register(np.str_, lambda x: conversion.py2rpy(str(x)))


@dict_converter.py2rpy.register(dict)
def py2rpy_dict(obj: dict) -> ListVector:
@dict_converter.py2rpy.register(Mapping)
def py2rpy_dict(obj: Mapping) -> ListVector:
"""Try converting everything. For nested dicts, this needs itself to be registered"""
converted = {}
for k, v in obj.items():
Expand Down

0 comments on commit 9a835b5

Please sign in to comment.