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))
评论列表
文章目录