".github/vscode:/vscode.git/clone" did not exist on "ba2ba9019f76fd96c532240ed07d3f98343e4041"
Unverified Commit f670152b authored by Yoshitomo Matsubara's avatar Yoshitomo Matsubara Committed by GitHub
Browse files

check if value exists without iteration (#5225)

parent 03d11338
......@@ -60,9 +60,8 @@ class WeightsEnum(Enum):
@classmethod
def from_str(cls, value: str) -> "WeightsEnum":
for k, v in cls.__members__.items():
if k == value:
return v
if value in cls.__members__:
return cls.__members__[value]
raise ValueError(f"Invalid value {value} for enum {cls.__name__}.")
def get_state_dict(self, progress: bool) -> OrderedDict:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment