提交 1c0dec42 authored 作者: abergeron's avatar abergeron

Merge pull request #2392 from dmitriy-serdyuk/none_checks

Fixed 'comparison with None' warnings
......@@ -1935,11 +1935,11 @@ def local_useless_subtensor(node):
# If idx is not a slice, this means we remove this dimension
# from the output, so the subtensor is not useless
return False
if idx.start not in [0, None]:
if idx.start is not None and idx.start != 0:
# If the start of the slice is different from 0, or is a
# variable, then we assume the subtensor is not useless
return False
if idx.step not in [1, None]:
if idx.step is not None and idx.step != 1:
# If we are going backwards, or skipping elements, then this
# is not a useless subtensor
return False
......@@ -2543,9 +2543,9 @@ def local_setsubtensor_of_constants(node):
except NotScalarConstantError:
pass
if (replace_x == replace_y and
replace_x is not None and
replace_y is not None):
if (replace_x is not None and
replace_y is not None and
replace_x == replace_y):
return [x]
else:
return False
......
......@@ -137,11 +137,11 @@ def get_canonical_form_slice(theslice, length):
# in the generic case below.
if step == 1:
is_start_0 = (
start in [None, 0] or
start is None or start == 0 or
(is_start_constant and is_length_constant and
start < 0 and start + length <= 0))
is_stop_length = (
stop in [None, length, maxsize] or
stop is None or stop in [length, maxsize] or
(is_stop_constant and is_length_constant and
stop >= length))
if is_start_0:
......@@ -217,7 +217,7 @@ def get_canonical_form_slice(theslice, length):
start = switch(ge(start, length),
switch_neg_step(length - 1, length),
start)
if stop in [None, maxsize]:
if stop is None or stop == maxsize:
# The special "maxsize" case is probably not needed here,
# as slices containing maxsize are not generated by
# __getslice__ anymore.
......@@ -478,7 +478,7 @@ class Subtensor(Op):
start = get_scalar_constant_value(start)
except NotScalarConstantError:
pass
if start in [None, 0]:
if start is None or start == 0:
start = p.start
if start is None:
start = 0
......
......@@ -369,7 +369,7 @@ class _tensor_py_operators:
axis = None
for i, arg in enumerate(args):
try:
if arg != numpy.newaxis:
if arg is not numpy.newaxis:
theano.tensor.subtensor.Subtensor.convert(arg)
except theano.tensor.subtensor.AdvancedIndexingError:
if advanced:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论