提交 c84494b8 authored 作者: Michael Osthege's avatar Michael Osthege 提交者: Brandon T. Willard

Rename ConfigParam.fullname to ConfigParam.name

上级 0e47020a
...@@ -130,12 +130,12 @@ class TheanoConfigParser: ...@@ -130,12 +130,12 @@ class TheanoConfigParser:
""" """
all_opts = sorted( all_opts = sorted(
[c for c in self._config_var_dict.values() if c.in_c_key], [c for c in self._config_var_dict.values() if c.in_c_key],
key=lambda cv: cv.fullname, key=lambda cv: cv.name,
) )
return _hash_from_code( return _hash_from_code(
"\n".join( "\n".join(
[ [
"{} = {}".format(cv.fullname, cv.__get__(self, self.__class__)) "{} = {}".format(cv.name, cv.__get__(self, self.__class__))
for cv in all_opts for cv in all_opts
] ]
) )
...@@ -170,7 +170,7 @@ class TheanoConfigParser: ...@@ -170,7 +170,7 @@ class TheanoConfigParser:
if hasattr(self, name): if hasattr(self, name):
raise AttributeError(f"The name {name} is already taken") raise AttributeError(f"The name {name} is already taken")
configparam.doc = doc configparam.doc = doc
configparam.fullname = name configparam.name = name
configparam.in_c_key = in_c_key configparam.in_c_key = in_c_key
# Trigger a read of the value from config files and env vars # Trigger a read of the value from config files and env vars
# This allow to filter wrong value from the user. # This allow to filter wrong value from the user.
...@@ -296,7 +296,7 @@ class ConfigParam: ...@@ -296,7 +296,7 @@ class ConfigParam:
self._mutable = mutable self._mutable = mutable
self.is_default = True self.is_default = True
# set by TheanoConfigParser.add: # set by TheanoConfigParser.add:
self.fullname = None self.name = None
self.doc = None self.doc = None
self.in_c_key = None self.in_c_key = None
...@@ -336,7 +336,7 @@ class ConfigParam: ...@@ -336,7 +336,7 @@ class ConfigParam:
return True return True
if self._validate(value) is False: if self._validate(value) is False:
raise ValueError( raise ValueError(
f"Invalid value ({value}) for configuration variable '{self.fullname}'." f"Invalid value ({value}) for configuration variable '{self.name}'."
) )
return True return True
...@@ -345,7 +345,7 @@ class ConfigParam: ...@@ -345,7 +345,7 @@ class ConfigParam:
return self return self
if not hasattr(self, "val"): if not hasattr(self, "val"):
try: try:
val_str = cls.fetch_val_for_key(self.fullname, delete_key=delete_key) val_str = cls.fetch_val_for_key(self.name, delete_key=delete_key)
self.is_default = False self.is_default = False
except KeyError: except KeyError:
if callable(self.default): if callable(self.default):
...@@ -358,7 +358,7 @@ class ConfigParam: ...@@ -358,7 +358,7 @@ class ConfigParam:
def __set__(self, cls, val): def __set__(self, cls, val):
if not self.mutable and hasattr(self, "val"): if not self.mutable and hasattr(self, "val"):
raise Exception( raise Exception(
"Can't change the value of {self.fullname} config parameter after initialization!" "Can't change the value of {self.name} config parameter after initialization!"
) )
applied = self.apply(val) applied = self.apply(val)
self.validate(applied) self.validate(applied)
...@@ -396,18 +396,18 @@ class EnumStr(ConfigParam): ...@@ -396,18 +396,18 @@ class EnumStr(ConfigParam):
return val return val
else: else:
raise ValueError( raise ValueError(
f"Invalid value ('{val}') for configuration variable '{self.fullname}'. " f"Invalid value ('{val}') for configuration variable '{self.name}'. "
f"Valid options are {self.all}" f"Valid options are {self.all}"
) )
def __str__(self): def __str__(self):
return f"{self.fullname} ({self.all}) " return f"{self.name} ({self.all}) "
class TypedParam(ConfigParam): class TypedParam(ConfigParam):
def __str__(self): def __str__(self):
# The "_apply" callable is the type itself. # The "_apply" callable is the type itself.
return f"{self.fullname} ({self._apply}) " return f"{self.name} ({self._apply}) "
class StrParam(TypedParam): class StrParam(TypedParam):
...@@ -440,7 +440,7 @@ class BoolParam(TypedParam): ...@@ -440,7 +440,7 @@ class BoolParam(TypedParam):
elif value in {True, 1, "true", "True", "1"}: elif value in {True, 1, "true", "True", "1"}:
return True return True
raise ValueError( raise ValueError(
f"Invalid value ({value}) for configuration variable '{self.fullname}'." f"Invalid value ({value}) for configuration variable '{self.name}'."
) )
...@@ -463,12 +463,12 @@ class DeviceParam(ConfigParam): ...@@ -463,12 +463,12 @@ class DeviceParam(ConfigParam):
else: else:
raise ValueError( raise ValueError(
'Invalid value ("{val}") for configuration ' 'Invalid value ("{val}") for configuration '
'variable "{self.fullname}". Valid options start with ' 'variable "{self.name}". Valid options start with '
'one of "cpu", "opencl" or "cuda".' 'one of "cpu", "opencl" or "cuda".'
) )
def __str__(self): def __str__(self):
return f"{self.fullname} ({self.default}, opencl*, cuda*) " return f"{self.name} ({self.default}, opencl*, cuda*) "
class ContextsParam(ConfigParam): class ContextsParam(ConfigParam):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论