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

Hide helper class and add docstring

上级 5bad1040
......@@ -565,14 +565,17 @@ def _create_default_config():
return config
# will be overwritten by configdefaults
class ConfigProxy:
class _ConfigProxy:
"""Like _SectionRedirect this class enables backwards-compatible access to the
config settings, but raises DeprecationWarnings with instructions to use `theano.config`.
"""
def __init__(self, actual):
ConfigProxy._actual = actual
_ConfigProxy._actual = actual
def __getattr__(self, attr):
if attr == "_actual":
return ConfigProxy._actual
return _ConfigProxy._actual
warnings.warn(
"Accessing config through `theano.configparser.config` is deprecated. "
"Use `theano.config` instead.",
......@@ -583,7 +586,7 @@ class ConfigProxy:
def __setattr__(self, attr, value):
if attr == "_actual":
return setattr(ConfigProxy._actual, attr, value)
return setattr(_ConfigProxy._actual, attr, value)
warnings.warn(
"Accessing config through `theano.configparser.config` is deprecated. "
"Use `theano.config` instead.",
......@@ -600,7 +603,7 @@ _config = _create_default_config()
# The old API often imported the default config object from `configparser`.
# These imports/accesses should be replaced with `theano.config`, so this wraps
# it with warnings:
config = ConfigProxy(_config)
config = _ConfigProxy(_config)
# We can't alias the methods of the `config` variable above without already
# triggering the warning. Instead, we wrap the methods of the actual instance
# with warnings:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论