未验证 提交 618fd8c0 编写于 作者: F Florian Bruggisser 提交者: GitHub

feat(exp): sequence support for exp options merge function (#1614)

feat(exp): sequence support for exp options merge function
上级 b3a80bee
......@@ -5,7 +5,7 @@
import ast
import pprint
from abc import ABCMeta, abstractmethod
from typing import Dict
from typing import Dict, List, Tuple
from tabulate import tabulate
import torch
......@@ -72,6 +72,17 @@ class BaseExp(metaclass=ABCMeta):
if hasattr(self, k):
src_value = getattr(self, k)
src_type = type(src_value)
# pre-process input if source type is list or tuple
if isinstance(src_value, List) or isinstance(src_value, Tuple):
v = v.strip("[]()")
v = [t.strip() for t in v.split(",")]
# find type of tuple
if len(src_value) > 0:
src_item_type = type(src_value[0])
v = [src_item_type(t) for t in v]
if src_value is not None and src_type != type(v):
try:
v = src_type(v)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册