Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
47853608
提交
47853608
authored
6月 29, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 for tensor/type.py ; one E left
上级
acd37bd7
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
17 行删除
+15
-17
type.py
theano/tensor/type.py
+15
-16
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/tensor/type.py
浏览文件 @
47853608
import
logging
import
logging
_logger
=
logging
.
getLogger
(
"theano.tensor.type"
)
import
warnings
import
numpy
import
numpy
import
theano
import
theano
from
theano
import
config
from
theano
import
config
from
theano.gof
import
Constant
,
hashtype
,
Type
,
Variable
from
theano.gof
import
hashtype
,
Type
,
Variable
from
theano.gof.utils
import
MethodNotDefined
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
_logger
=
logging
.
getLogger
(
"theano.tensor.type"
)
class
TensorType
(
Type
):
class
TensorType
(
Type
):
"""Symbolic `Type` representing a numpy.ndarray value."""
"""Symbolic `Type` representing a numpy.ndarray value."""
...
@@ -39,7 +40,7 @@ class TensorType(Type):
...
@@ -39,7 +40,7 @@ class TensorType(Type):
if
self
.
dtype
==
'floatX'
:
if
self
.
dtype
==
'floatX'
:
self
.
dtype
=
config
.
floatX
self
.
dtype
=
config
.
floatX
# broadcastable is immutable, and all elements are either
# broadcastable is immutable, and all elements are either
#
##
True or False
# True or False
self
.
broadcastable
=
tuple
(
bool
(
b
)
for
b
in
broadcastable
)
self
.
broadcastable
=
tuple
(
bool
(
b
)
for
b
in
broadcastable
)
self
.
dtype_specs
()
# error checking is done there
self
.
dtype_specs
()
# error checking is done there
self
.
name
=
name
self
.
name
=
name
...
@@ -78,13 +79,13 @@ class TensorType(Type):
...
@@ -78,13 +79,13 @@ class TensorType(Type):
'maybe you are trying to call a function on a (possibly '
'maybe you are trying to call a function on a (possibly '
'shared) variable instead of a numeric array?'
)
'shared) variable instead of a numeric array?'
)
if
((
type
(
data
)
is
numpy
.
ndarray
)
if
((
type
(
data
)
is
numpy
.
ndarray
)
and
and
(
data
.
dtype
==
self
.
numpy_dtype
)):
(
data
.
dtype
==
self
.
numpy_dtype
)):
if
data
.
dtype
.
num
!=
self
.
numpy_dtype
.
num
:
if
data
.
dtype
.
num
!=
self
.
numpy_dtype
.
num
:
data
=
theano
.
_asarray
(
data
,
dtype
=
self
.
dtype
)
data
=
theano
.
_asarray
(
data
,
dtype
=
self
.
dtype
)
# -- now fall through to ndim check
# -- now fall through to ndim check
elif
((
type
(
data
)
is
numpy
.
memmap
)
elif
((
type
(
data
)
is
numpy
.
memmap
)
and
and
(
data
.
dtype
==
self
.
numpy_dtype
)):
(
data
.
dtype
==
self
.
numpy_dtype
)):
# numpy.memmap is a "safe" subclass of ndarray,
# numpy.memmap is a "safe" subclass of ndarray,
# so we can use it whereever we expect a base ndarray.
# so we can use it whereever we expect a base ndarray.
# however, casting it would defeat the purpose of not
# however, casting it would defeat the purpose of not
...
@@ -98,8 +99,8 @@ class TensorType(Type):
...
@@ -98,8 +99,8 @@ class TensorType(Type):
data
,
type
(
data
))
data
,
type
(
data
))
if
data
.
dtype
!=
self
.
numpy_dtype
:
if
data
.
dtype
!=
self
.
numpy_dtype
:
raise
TypeError
((
"
%
s expected a ndarray object with "
raise
TypeError
((
"
%
s expected a ndarray object with "
"dtype =
%
s (got
%
s)."
)
%
(
"dtype =
%
s (got
%
s)."
)
%
self
,
self
.
numpy_dtype
,
data
.
dtype
))
(
self
,
self
.
numpy_dtype
,
data
.
dtype
))
assert
False
,
"This point should never be reached."
assert
False
,
"This point should never be reached."
else
:
else
:
if
allow_downcast
:
if
allow_downcast
:
...
@@ -210,12 +211,10 @@ class TensorType(Type):
...
@@ -210,12 +211,10 @@ class TensorType(Type):
raise
TypeError
(
raise
TypeError
(
'Cannot convert Type
%(othertype)
s '
'Cannot convert Type
%(othertype)
s '
'(of Variable
%(other)
s) into Type
%(self)
s. '
'(of Variable
%(other)
s) into Type
%(self)
s. '
'You can try to manually convert
%(other)
s into a
%(self)
s.'
'You can try to manually convert
%(other)
s into a
%(self)
s.'
%
%
dict
(
dict
(
othertype
=
other
.
type
,
othertype
=
other
.
type
,
other
=
other
,
other
=
other
,
self
=
self
)
self
=
self
))
)
def
value_validity_msg
(
self
,
a
):
def
value_validity_msg
(
self
,
a
):
try
:
try
:
...
@@ -422,7 +421,7 @@ class TensorType(Type):
...
@@ -422,7 +421,7 @@ class TensorType(Type):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
str
(
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
):
def
c_declare
(
self
,
name
,
sub
,
check_input
=
True
):
"""Override `CLinkerType.c_declare` """
"""Override `CLinkerType.c_declare` """
...
...
theano/tests/test_flake8.py
浏览文件 @
47853608
...
@@ -57,7 +57,6 @@ whitelist_flake8 = [
...
@@ -57,7 +57,6 @@ whitelist_flake8 = [
"typed_list/tests/test_type.py"
,
"typed_list/tests/test_type.py"
,
"typed_list/tests/test_opt.py"
,
"typed_list/tests/test_opt.py"
,
"typed_list/tests/test_basic.py"
,
"typed_list/tests/test_basic.py"
,
"tensor/type.py"
,
"tensor/fourier.py"
,
"tensor/fourier.py"
,
"tensor/__init__.py"
,
"tensor/__init__.py"
,
"tensor/opt_uncanonicalize.py"
,
"tensor/opt_uncanonicalize.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论