提交 47853608 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

flake8 for tensor/type.py ; one E left

上级 acd37bd7
import logging
_logger = logging.getLogger("theano.tensor.type")
import warnings
import numpy
import theano
from theano import config
from theano.gof import Constant, hashtype, Type, Variable
from theano.gof.utils import MethodNotDefined
from theano.gof import hashtype, Type, Variable
from theano import scalar as scal
_logger = logging.getLogger("theano.tensor.type")
class TensorType(Type):
"""Symbolic `Type` representing a numpy.ndarray value."""
......@@ -39,7 +40,7 @@ class TensorType(Type):
if self.dtype == 'floatX':
self.dtype = config.floatX
# broadcastable is immutable, and all elements are either
### True or False
# True or False
self.broadcastable = tuple(bool(b) for b in broadcastable)
self.dtype_specs() # error checking is done there
self.name = name
......@@ -78,13 +79,13 @@ class TensorType(Type):
'maybe you are trying to call a function on a (possibly '
'shared) variable instead of a numeric array?')
if ((type(data) is numpy.ndarray)
and (data.dtype == self.numpy_dtype)):
if ((type(data) is numpy.ndarray) and
(data.dtype == self.numpy_dtype)):
if data.dtype.num != self.numpy_dtype.num:
data = theano._asarray(data, dtype=self.dtype)
# -- now fall through to ndim check
elif((type(data) is numpy.memmap)
and (data.dtype == self.numpy_dtype)):
elif ((type(data) is numpy.memmap) and
(data.dtype == self.numpy_dtype)):
# numpy.memmap is a "safe" subclass of ndarray,
# so we can use it whereever we expect a base ndarray.
# however, casting it would defeat the purpose of not
......@@ -98,8 +99,8 @@ class TensorType(Type):
data, type(data))
if data.dtype != self.numpy_dtype:
raise TypeError(("%s expected a ndarray object with "
"dtype = %s (got %s).") % (
self, self.numpy_dtype, data.dtype))
"dtype = %s (got %s).") %
(self, self.numpy_dtype, data.dtype))
assert False, "This point should never be reached."
else:
if allow_downcast:
......@@ -210,12 +211,10 @@ class TensorType(Type):
raise TypeError(
'Cannot convert Type %(othertype)s '
'(of Variable %(other)s) into Type %(self)s. '
'You can try to manually convert %(other)s into a %(self)s.'
% dict(
othertype=other.type,
'You can try to manually convert %(other)s into a %(self)s.' %
dict(othertype=other.type,
other=other,
self=self)
)
self=self))
def value_validity_msg(self, a):
try:
......@@ -422,7 +421,7 @@ class TensorType(Type):
def __repr__(self):
return str(self)
#"TensorType{%s, %s}" % (str(self.dtype), str(self.broadcastable))
# "TensorType{%s, %s}" % (str(self.dtype), str(self.broadcastable))
def c_declare(self, name, sub, check_input=True):
"""Override `CLinkerType.c_declare` """
......
......@@ -57,7 +57,6 @@ whitelist_flake8 = [
"typed_list/tests/test_type.py",
"typed_list/tests/test_opt.py",
"typed_list/tests/test_basic.py",
"tensor/type.py",
"tensor/fourier.py",
"tensor/__init__.py",
"tensor/opt_uncanonicalize.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论