提交 c7add2a3 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Flake8 for compile/sharedvalue.py

上级 d5ff2b48
...@@ -49,7 +49,8 @@ class SharedVariable(Variable): ...@@ -49,7 +49,8 @@ class SharedVariable(Variable):
or copied, so they must have the correct type. or copied, so they must have the correct type.
:param allow_downcast: Only applies if `strict` is False. :param allow_downcast: Only applies if `strict` is False.
True -> allow assigned value to lose precision when cast during assignment. True -> allow assigned value to lose precision when cast
during assignment.
False -> never allow precision loss. False -> never allow precision loss.
None -> only allow downcasting of a Python float to a scalar floatX. None -> only allow downcasting of a Python float to a scalar floatX.
...@@ -65,12 +66,13 @@ class SharedVariable(Variable): ...@@ -65,12 +66,13 @@ class SharedVariable(Variable):
if container is not None: if container is not None:
self.container = container self.container = container
if (value is not None) or (strict is not None): if (value is not None) or (strict is not None):
raise TypeError( raise TypeError('value and strict are ignored if you pass '
'value and strict are ignored if you pass a container here') 'a container here')
else: else:
if container is not None: if container is not None:
raise TypeError('Error to specify both value and container') raise TypeError('Error to specify both value and container')
self.container = Container(self, self.container = Container(
self,
storage=[type.filter(value, strict=strict, storage=[type.filter(value, strict=strict,
allow_downcast=allow_downcast)], allow_downcast=allow_downcast)],
readonly=False, readonly=False,
...@@ -183,7 +185,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs): ...@@ -183,7 +185,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
potential constructors to those that can accept those kwargs. potential constructors to those that can accept those kwargs.
:note: Some shared variable have ``borrow`` as extra kwargs. :note: Some shared variable have ``borrow`` as extra kwargs.
`See <http://deeplearning.net/software/theano/tutorial/aliasing.html#borrowing-when-creating-shared-variables>`_ for detail. `See <http://deeplearning.net/software/theano/tutorial/aliasing.\
html#borrowing-when-creating-shared-variables>`_ for detail.
:note: Some shared variable have ``broadcastable`` as extra kwargs. :note: Some shared variable have ``broadcastable`` as extra kwargs.
As shared variable shapes can change, all dimensions default As shared variable shapes can change, all dimensions default
...@@ -200,7 +203,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs): ...@@ -200,7 +203,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
try: try:
if isinstance(value, Variable): if isinstance(value, Variable):
raise TypeError(" Shared variable constructor needs numeric values and not symbolic variables.") raise TypeError("Shared variable constructor needs numeric "
"values and not symbolic variables.")
for ctor in reversed(shared.constructors): for ctor in reversed(shared.constructors):
try: try:
......
...@@ -41,7 +41,6 @@ whitelist_flake8 = [ ...@@ -41,7 +41,6 @@ whitelist_flake8 = [
"compile/__init__.py", "compile/__init__.py",
"compile/profiling.py", "compile/profiling.py",
"compile/function_module.py", "compile/function_module.py",
"compile/sharedvalue.py",
"compile/monitormode.py", "compile/monitormode.py",
"compile/io.py", "compile/io.py",
"compile/tests/test_builders.py", "compile/tests/test_builders.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论