atset.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:ReGraph 作者: eugeniashurko 项目源码 文件源码
def to_atset(value):
    """Convert an attribute value to AtSet object."""
    if isinstance(value, str):
        symset = safe_sympify(value)
        # check that there are no symbols
        return AtSet(convert(AtSymSet(symset)), AtEmptySet())
    elif isinstance(value, list) or isinstance(value, set):
        str_vals = []
        num_vals = []
        for val in value:
            if test_number(val):
                num_vals.append(val)
            else:
                str_vals.append(val)
        res = AtSet(convert(AtFinSet(set(sympify(num_vals)))),
                    convert(AtPosStringSet(set(str_vals))))
        return res
    elif isinstance(value, dict):
        return AtSet.from_json(value)
    elif isinstance(value, AtSet):
        return value
    else:
        raise ReGraphError("value {} should be a list, set, string or dict "
                           "representation of AtSet".format(value))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号