def is_convertible(obj):
allowed_types = [ComplexSfix, Sfix, int, bool, Const]
if type(obj) in allowed_types:
return True
elif isinstance(obj, list):
# To check whether all elements are of the same type
if len(set(map(type, obj))) == 1:
if all(type(x) in allowed_types for x in obj):
return True
elif isinstance(obj[0], HW): # list of submodules
return True
elif isinstance(obj, Enum):
return True
elif isinstance(obj, HW):
return True
return False
评论列表
文章目录