Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8634f09d
提交
8634f09d
authored
9月 13, 2011
作者:
David Warde-Farley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BUG: str -> basestring isinstance checks.
上级
b86b4389
隐藏空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
36 行增加
和
36 行删除
+36
-36
debugging_with_stepmode.txt
doc/sandbox/debugging_with_stepmode.txt
+2
-2
debugmode.py
theano/compile/debugmode.py
+1
-1
function_module.py
theano/compile/function_module.py
+1
-1
io.py
theano/compile/io.py
+2
-2
mode.py
theano/compile/mode.py
+5
-5
module.py
theano/compile/module.py
+2
-2
profilemode.py
theano/compile/profilemode.py
+2
-2
configparser.py
theano/configparser.py
+1
-1
cc.py
theano/gof/cc.py
+2
-2
cmodule.py
theano/gof/cmodule.py
+2
-2
graph.py
theano/gof/graph.py
+1
-1
opt.py
theano/gof/opt.py
+2
-2
equilibrium.py
theano/gof/sandbox/equilibrium.py
+2
-2
test_op.py
theano/gof/tests/test_op.py
+1
-1
pycuda_example.py
theano/misc/pycuda_example.py
+1
-1
printing.py
theano/printing.py
+1
-1
symbolic_module.py
theano/sandbox/symbolic_module.py
+2
-2
scan_op.py
theano/scan_module/scan_op.py
+2
-2
scan_utils.py
theano/scan_module/scan_utils.py
+2
-2
basic.py
theano/sparse/basic.py
+1
-1
raw_random.py
theano/tensor/raw_random.py
+1
-1
没有找到文件。
doc/sandbox/debugging_with_stepmode.txt
浏览文件 @
8634f09d
...
...
@@ -46,12 +46,12 @@ purpose of it is to hack it to investigate what your own particular program is d
self.provided_linker = linker
self.provided_optimizer = optimizer
if isinstance(linker,
str
) or linker is None:
if isinstance(linker,
basestring
) or linker is None:
linker = predefined_linkers[linker]
self.linker = WrapLinkerMany([linker], [blah])
if isinstance(optimizer,
str
) or optimizer is None:
if isinstance(optimizer,
basestring
) or optimizer is None:
optimizer = predefined_optimizers[optimizer]
self._optimizer = optimizer
...
...
theano/compile/debugmode.py
浏览文件 @
8634f09d
...
...
@@ -58,7 +58,7 @@ AddConfigVar('DebugMode.warn_input_not_reused',
in_c_key
=
False
)
def
is_valid_check_preallocated_output_param
(
param
):
if
not
isinstance
(
param
,
str
):
if
not
isinstance
(
param
,
basestring
):
return
False
valid
=
[
"previous"
,
"c_contiguous"
,
"f_contiguous"
,
"neg_strides"
,
"ALL"
,
""
]
for
p
in
param
.
split
(
":"
):
...
...
theano/compile/function_module.py
浏览文件 @
8634f09d
...
...
@@ -1272,7 +1272,7 @@ def convert_function_input(input):
orig
=
input
if
not
input
:
raise
TypeError
(
"Nonsensical input specification:
%
s"
%
input
)
if
isinstance
(
input
[
0
],
str
):
if
isinstance
(
input
[
0
],
basestring
):
name
=
input
[
0
]
input
=
input
[
1
:]
else
:
...
...
theano/compile/io.py
浏览文件 @
8634f09d
...
...
@@ -56,7 +56,7 @@ class SymbolicInput(object):
else
:
self
.
name
=
name
if
self
.
name
is
not
None
and
not
isinstance
(
self
.
name
,
str
):
if
self
.
name
is
not
None
and
not
isinstance
(
self
.
name
,
basestring
):
raise
TypeError
(
"name must be a string! (got:
%
s)"
%
self
.
name
)
self
.
update
=
update
if
(
mutable
is
not
None
):
...
...
@@ -90,7 +90,7 @@ class SymbolicInputKit(object):
"""
def
__init__
(
self
,
name
):
if
not
isinstance
(
name
,
str
):
if
not
isinstance
(
name
,
basestring
):
raise
TypeError
(
'naem must be a string (got:
%
s)'
%
name
)
self
.
name
=
name
self
.
sinputs
=
[]
...
...
theano/compile/mode.py
浏览文件 @
8634f09d
...
...
@@ -245,10 +245,10 @@ class Mode(object):
linker
,
optimizer
=
state
self
.
provided_linker
=
linker
self
.
provided_optimizer
=
optimizer
if
isinstance
(
linker
,
str
)
or
linker
is
None
:
if
isinstance
(
linker
,
basestring
)
or
linker
is
None
:
linker
=
predefined_linkers
[
linker
]
self
.
linker
=
linker
if
isinstance
(
optimizer
,
str
)
or
optimizer
is
None
:
if
isinstance
(
optimizer
,
basestring
)
or
optimizer
is
None
:
optimizer
=
predefined_optimizers
[
optimizer
]
if
isinstance
(
optimizer
,
gof
.
Query
):
self
.
provided_optimizer
=
optimizer
...
...
@@ -271,9 +271,9 @@ class Mode(object):
optimizer
=
property
(
__get_optimizer
)
def
get_linker_optimizer
(
self
,
linker
,
optimizer
):
if
isinstance
(
linker
,
str
)
or
linker
is
None
:
if
isinstance
(
linker
,
basestring
)
or
linker
is
None
:
linker
=
predefined_linkers
[
linker
]
if
isinstance
(
optimizer
,
str
)
or
optimizer
is
None
:
if
isinstance
(
optimizer
,
basestring
)
or
optimizer
is
None
:
optimizer
=
predefined_optimizers
[
optimizer
]
return
(
linker
,
optimizer
)
...
...
@@ -313,7 +313,7 @@ def get_mode(orig_string):
string
=
config
.
mode
else
:
string
=
orig_string
if
not
isinstance
(
string
,
str
):
if
not
isinstance
(
string
,
basestring
):
return
string
#it is hopefully already a mode...
global
instanciated_default_mode
...
...
theano/compile/module.py
浏览文件 @
8634f09d
...
...
@@ -305,7 +305,7 @@ class Method(Component):
# return self.resolve(x).r
def
resolve_inputs
():
if
isinstance
(
self
.
inputs
,
(
io
.
In
,
gof
.
Variable
,
str
)):
if
isinstance
(
self
.
inputs
,
(
io
.
In
,
gof
.
Variable
,
basestring
)):
inputs
=
[
self
.
inputs
]
else
:
inputs
=
list
(
self
.
inputs
)
...
...
@@ -313,7 +313,7 @@ class Method(Component):
passthrough
=
(
gof
.
Variable
,
io
.
In
))
for
input
in
inputs
]
def
resolve_outputs
():
if
isinstance
(
self
.
outputs
,
(
io
.
Out
,
gof
.
Variable
,
str
,
type
(
None
))):
if
isinstance
(
self
.
outputs
,
(
io
.
Out
,
gof
.
Variable
,
basestring
,
type
(
None
))):
output
=
self
.
outputs
self
.
outputs
=
resolve_variable
(
output
,
passthrough
=
(
gof
.
Variable
,
io
.
Out
,
type
(
None
)))
...
...
theano/compile/profilemode.py
浏览文件 @
8634f09d
...
...
@@ -184,7 +184,7 @@ class ProfileMode(Mode):
self
.
provided_linker
=
linker
self
.
provided_optimizer
=
optimizer
if
isinstance
(
linker
,
str
)
or
linker
is
None
:
if
isinstance
(
linker
,
basestring
)
or
linker
is
None
:
linker
=
predefined_linkers
[
linker
]
if
not
config
.
ProfileMode
.
profile_memory
:
...
...
@@ -194,7 +194,7 @@ class ProfileMode(Mode):
linker
=
WrapLinker
([
linker
],
p_thunk
)
self
.
linker
=
linker
if
isinstance
(
optimizer
,
str
)
or
optimizer
is
None
:
if
isinstance
(
optimizer
,
basestring
)
or
optimizer
is
None
:
optimizer
=
predefined_optimizers
[
optimizer
]
self
.
_optimizer
=
optimizer
...
...
theano/configparser.py
浏览文件 @
8634f09d
...
...
@@ -243,7 +243,7 @@ class EnumStr(ConfigParam):
# All options should be strings
for
val
in
self
.
all
:
if
not
isinstance
(
val
,
str
):
if
not
isinstance
(
val
,
basestring
):
raise
ValueError
(
'Valid values for an EnumStr parameter '
'should be strings'
,
val
,
type
(
val
))
...
...
theano/gof/cc.py
浏览文件 @
8634f09d
...
...
@@ -521,7 +521,7 @@ class CLinker(link.Linker):
pass
else
:
# The following will be executed if the "try" block succeeds
assert
isinstance
(
c_support_code_apply
[
-
1
],
str
),
(
assert
isinstance
(
c_support_code_apply
[
-
1
],
basestring
),
(
str
(
node
.
op
)
+
" didn't returned a string for c_support_code_apply"
)
# emit c_code
...
...
@@ -529,7 +529,7 @@ class CLinker(link.Linker):
behavior
=
op
.
c_code
(
node
,
name
,
isyms
,
osyms
,
sub
)
except
utils
.
MethodNotDefined
:
raise
NotImplementedError
(
"
%
s cannot produce C code"
%
op
)
assert
isinstance
(
behavior
,
str
),
str
(
node
.
op
)
+
" didn't returned a string for c_code"
assert
isinstance
(
behavior
,
basestring
),
str
(
node
.
op
)
+
" didn't returned a string for c_code"
try
:
cleanup
=
op
.
c_code_cleanup
(
node
,
name
,
isyms
,
osyms
,
sub
)
...
...
theano/gof/cmodule.py
浏览文件 @
8634f09d
...
...
@@ -268,7 +268,7 @@ def get_module_hash(src_code, key):
# This should be the C++ compilation command line parameters or the
# libraries to link against.
to_hash
+=
list
(
key_element
)
elif
isinstance
(
key_element
,
str
):
elif
isinstance
(
key_element
,
basestring
):
if
key_element
.
startswith
(
'md5:'
):
# This is the md5 hash of the config options. We can stop
# here.
...
...
@@ -298,7 +298,7 @@ def get_safe_part(key):
# Find the md5 hash part.
c_link_key
=
key
[
1
]
for
key_element
in
c_link_key
[
1
:]:
if
isinstance
(
key_element
,
str
)
and
key_element
.
startswith
(
'md5:'
):
if
isinstance
(
key_element
,
basestring
)
and
key_element
.
startswith
(
'md5:'
):
md5
=
key_element
[
4
:]
break
...
...
theano/gof/graph.py
浏览文件 @
8634f09d
...
...
@@ -269,7 +269,7 @@ class Variable(utils.object2):
if
index
is
not
None
and
not
isinstance
(
index
,
int
):
raise
TypeError
(
"index must be an int"
,
index
)
self
.
index
=
index
if
name
is
not
None
and
not
isinstance
(
name
,
str
):
if
name
is
not
None
and
not
isinstance
(
name
,
basestring
):
raise
TypeError
(
"name must be a string"
,
name
)
self
.
name
=
name
def
__str__
(
self
):
...
...
theano/gof/opt.py
浏览文件 @
8634f09d
...
...
@@ -698,7 +698,7 @@ class PatternSub(LocalOptimizer):
return
match
(
real_pattern
,
expr
,
u
,
pattern
.
get
(
'allow_multiple_clients'
,
allow_multiple_clients
))
else
:
return
retry_with_equiv
()
elif
isinstance
(
pattern
,
str
):
elif
isinstance
(
pattern
,
basestring
):
v
=
unify
.
Var
(
pattern
)
if
u
[
v
]
is
not
v
and
u
[
v
]
is
not
expr
:
return
retry_with_equiv
()
...
...
@@ -721,7 +721,7 @@ class PatternSub(LocalOptimizer):
if
isinstance
(
pattern
,
(
list
,
tuple
)):
args
=
[
build
(
p
,
u
)
for
p
in
pattern
[
1
:]]
return
pattern
[
0
](
*
args
)
elif
isinstance
(
pattern
,
str
):
elif
isinstance
(
pattern
,
basestring
):
return
u
[
unify
.
Var
(
pattern
)]
elif
isinstance
(
pattern
,
(
int
,
float
)):
return
pattern
...
...
theano/gof/sandbox/equilibrium.py
浏览文件 @
8634f09d
...
...
@@ -63,7 +63,7 @@ if 0:
_nodes
=
nodes
nodes
=
reduce
(
list
.
__iadd__
,
[
reduce
(
list
.
__iadd__
,
[[
n
for
n
,
i
in
out
.
clients
if
not
isinstance
(
n
,
str
)]
for
out
in
node
.
outputs
],
[[
n
for
n
,
i
in
out
.
clients
if
not
isinstance
(
n
,
basestring
)]
for
out
in
node
.
outputs
],
[])
for
node
in
nodes
],
[])
candidates
=
tracks
...
...
@@ -121,7 +121,7 @@ if 0:
# for candidate in candidates:
# if candidate.current.inputs is not None:
# for in1, in2 in zip(candidate.current.inputs, node.inputs):
# if isinstance(in1,
str
):
# if isinstance(in1,
basestring
):
# candidate.match[in1] = in2
# for client in node.clients:
...
...
theano/gof/tests/test_op.py
浏览文件 @
8634f09d
...
...
@@ -33,7 +33,7 @@ class MyType(Type):
def
filter
(
self
,
x
,
strict
=
False
,
allow_downcast
=
None
):
# Dummy filter: we want this type to represent strings that
# start with `self.thingy`.
assert
isinstance
(
x
,
str
)
and
x
.
startswith
(
self
.
thingy
)
assert
isinstance
(
x
,
basestring
)
and
x
.
startswith
(
self
.
thingy
)
return
x
class
MyOp
(
Op
):
...
...
theano/misc/pycuda_example.py
浏览文件 @
8634f09d
...
...
@@ -45,7 +45,7 @@ def theano_parse_c_arg(c_arg):
class
TheanoElementwiseKernel
(
pycuda
.
elementwise
.
ElementwiseKernel
):
def
__init__
(
self
,
arguments
,
operation
,
name
=
"kernel"
,
keep
=
False
,
options
=
[],
**
kwargs
):
if
isinstance
(
arguments
,
str
):
if
isinstance
(
arguments
,
basestring
):
arguments
=
[
theano_parse_c_arg
(
arg
)
for
arg
in
arguments
.
split
(
","
)]
pycuda
.
elementwise
.
ElementwiseKernel
.
__init__
(
self
,
arguments
,
operation
,
name
,
keep
,
options
,
**
kwargs
)
...
...
theano/printing.py
浏览文件 @
8634f09d
...
...
@@ -190,7 +190,7 @@ class PatternPrinter:
def
__init__
(
self
,
*
patterns
):
self
.
patterns
=
[]
for
pattern
in
patterns
:
if
isinstance
(
pattern
,
str
):
if
isinstance
(
pattern
,
basestring
):
self
.
patterns
.
append
((
pattern
,
()))
else
:
self
.
patterns
.
append
((
pattern
[
0
],
pattern
[
1
:]))
...
...
theano/sandbox/symbolic_module.py
浏览文件 @
8634f09d
...
...
@@ -119,7 +119,7 @@ def compile(smod, initial_values={}):
elif
issymbolicmodule
(
val
):
for
s
in
modwalker
(
val
.
__dict__
,
[
v
for
k
,
v
in
sym_items
(
val
)]):
yield
s
elif
isinstance
(
val
,
(
str
,
int
,
float
)):
elif
isinstance
(
val
,
(
basestring
,
int
,
float
)):
pass
elif
isinstance
(
val
,
theano
.
Variable
):
pass
...
...
@@ -170,7 +170,7 @@ def compile(smod, initial_values={}):
reflected
[
thing
]
=
cmod
for
key
,
val
in
sym_items
(
thing
):
setattr
(
CMod
,
key
,
reflect
(
val
))
elif
isinstance
(
thing
,
(
str
,
int
,
float
)):
elif
isinstance
(
thing
,
(
basestring
,
int
,
float
)):
reflected
[
thing
]
=
thing
elif
isinstance
(
thing
,
theano
.
Variable
):
if
thing
.
owner
is
None
:
...
...
theano/scan_module/scan_op.py
浏览文件 @
8634f09d
...
...
@@ -355,9 +355,9 @@ class Scan(PureOp):
self
.
outputs
[:
slices
]
]
wrapped_outputs
+=
self
.
outputs
[
slices
:]
profile
=
None
if
(
theano
.
config
.
profile
or
(
isinstance
(
self
.
profile
,
(
str
,
bool
,
int
))
if
(
theano
.
config
.
profile
or
(
isinstance
(
self
.
profile
,
(
basestring
,
bool
,
int
))
and
self
.
profile
)):
if
isinstance
(
self
.
profile
,
str
):
if
isinstance
(
self
.
profile
,
basestring
):
profile
=
ScanProfileStats
(
name
=
self
.
profile
)
else
:
profile
=
ScanProfileStats
(
name
=
self
.
name
)
...
...
theano/scan_module/scan_utils.py
浏览文件 @
8634f09d
...
...
@@ -245,7 +245,7 @@ def isNaN_or_Inf_or_None(x):
try
:
isNaN
=
numpy
.
isnan
(
x
)
isInf
=
numpy
.
isinf
(
x
)
isStr
=
isinstance
(
x
,
str
)
isStr
=
isinstance
(
x
,
basestring
)
except
Exception
:
isNaN
=
False
isInf
=
False
...
...
@@ -258,7 +258,7 @@ def isNaN_or_Inf_or_None(x):
except
Exception
:
isNaN
=
False
isInf
=
False
if
isinstance
(
x
,
gof
.
Constant
)
and
isinstance
(
x
.
data
,
str
):
if
isinstance
(
x
,
gof
.
Constant
)
and
isinstance
(
x
.
data
,
basestring
):
isStr
=
True
else
:
isStr
=
False
...
...
theano/sparse/basic.py
浏览文件 @
8634f09d
...
...
@@ -239,7 +239,7 @@ class SparseType(gof.Type):
else
:
raise
NotImplementedError
(
'unsupported dtype "
%
s" not in list'
%
dtype
,
list
(
self
.
dtype_set
))
assert
isinstance
(
format
,
str
)
assert
isinstance
(
format
,
basestring
)
if
format
in
self
.
format_cls
:
self
.
format
=
format
else
:
...
...
theano/tensor/raw_random.py
浏览文件 @
8634f09d
...
...
@@ -105,7 +105,7 @@ class RandomFunction(gof.Op):
def
__setstate__
(
self
,
state
):
self
.
state
=
state
fn
,
outtype
,
inplace
,
ndim_added
=
state
if
isinstance
(
fn
,
str
):
if
isinstance
(
fn
,
basestring
):
self
.
fn
=
getattr
(
numpy
.
random
.
RandomState
,
fn
)
else
:
self
.
fn
=
fn
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论