Exemple #1
0
def to_elementary(obj: typing.Dict) -> typing.Dict:
    """

    :param d:
    :return:
    """

    if isinstance(obj, dict):
        re = dict()
        for k in obj:
            re[k] = to_elementary(obj[k])
        return re
    else:
        if isinstance(obj, (str, float, int, bool)) or obj is None:
            return obj
        elif isinstance(obj, np.ndarray):
            return obj.tolist()
        elif isinstance(obj, list):
            return [to_elementary(e) for e in obj]
        elif isinstance(obj, chisurf.base.Base):
            print(obj.name)
            return to_elementary(obj.to_dict())
        else:
            return None