소스 검색

change in how choice types selection is handled with the get method

Dimitri Korsch 4 년 전
부모
커밋
f87ead58ad
1개의 변경된 파일8개의 추가작업 그리고 6개의 파일을 삭제
  1. 8 6
      cvargparse/utils/enumerations.py

+ 8 - 6
cvargparse/utils/enumerations.py

@@ -34,13 +34,15 @@ class BaseChoiceType(Enum, metaclass=MetaBaseType):
 		return {e.name.lower(): e for e in cls}
 
 	@classmethod
-	def get(cls, key):
-		if isinstance(key, str):
-			return cls[key] if key in cls else cls.Default
-		elif isinstance(key, cls):
+	def get(cls, key=None):
+
+		if isinstance(key, str) and key in cls:
+			return cls[key]
+
+		if isinstance(key, cls):
 			return key
-		else:
-			raise ValueError("Unknown optimizer type: \"{}\"".format(key.__class__.__name__))
+
+		return cls.Default
 
 	@classmethod
 	def as_arg(cls, name, short_name=None, default=None, help_text=None, **kwargs):