Merge pull request #40240 from cclauss:Fix-SyntaxWarnings
PiperOrigin-RevId: 317145119 Change-Id: I724dda9028bcacd21ba04b4f6f81d013247617f2
This commit is contained in:
commit
f84adde4cf
|
@ -56,7 +56,7 @@ def _GetMatrixBandPartTest(dtype_, batch_shape_, shape_):
|
|||
band_np = np.triu(band_np, -lower)
|
||||
if upper >= 0:
|
||||
band_np = np.tril(band_np, upper)
|
||||
if batch_shape_ is not ():
|
||||
if batch_shape_ != ():
|
||||
band_np = np.tile(band_np, batch_shape_ + (1, 1))
|
||||
for index_dtype in [dtypes_lib.int32, dtypes_lib.int64]:
|
||||
with self.cached_session(use_gpu=False):
|
||||
|
|
|
@ -107,7 +107,7 @@ class MatrixSolveLsOpTest(test_lib.TestCase):
|
|||
np_ans = _SolveWithNumpy(x, y, l2_regularizer=l2_regularizer)
|
||||
np_r = np.dot(np.conj(a.T), b - np.dot(a, np_ans))
|
||||
np_r_norm = np.sqrt(np.sum(np.conj(np_r) * np_r))
|
||||
if batch_shape is not ():
|
||||
if batch_shape != ():
|
||||
a = np.tile(a, batch_shape + (1, 1))
|
||||
b = np.tile(b, batch_shape + (1, 1))
|
||||
np_ans = np.tile(np_ans, batch_shape + (1, 1))
|
||||
|
|
|
@ -81,8 +81,7 @@ def batch_gather_with_default(params,
|
|||
return_dtype=True))
|
||||
# TODO(hterry): lift this restriction and support default_values of
|
||||
# of rank > 1
|
||||
if (default_value.shape.ndims is not 0
|
||||
and default_value.shape.ndims is not 1):
|
||||
if default_value.shape.ndims not in (0, 1):
|
||||
raise ValueError('"default_value" must be a scalar or vector')
|
||||
upper_bounds = None
|
||||
if indices.shape.ndims is None:
|
||||
|
|
|
@ -288,8 +288,8 @@ def random_uniform(shape,
|
|||
shape = tensor_util.shape_tensor(shape)
|
||||
# In case of [0,1) floating results, minval and maxval is unused. We do an
|
||||
# `is` comparison here since this is cheaper than isinstance or __eq__.
|
||||
minval_is_zero = minval is 0 # pylint: disable=literal-comparison
|
||||
maxval_is_one = maxval is 1 # pylint: disable=literal-comparison
|
||||
minval_is_zero = isinstance(minval, int) and minval == 0
|
||||
maxval_is_one = isinstance(maxval, int) and maxval == 1
|
||||
if not minval_is_zero or not maxval_is_one or dtype.is_integer:
|
||||
minval = ops.convert_to_tensor(minval, dtype=dtype, name="min")
|
||||
maxval = ops.convert_to_tensor(maxval, dtype=dtype, name="max")
|
||||
|
|
|
@ -240,10 +240,11 @@ class DocGeneratorVisitor(object):
|
|||
# We cannot use the duplicate mechanism for some constants, since e.g.,
|
||||
# id(c1) == id(c2) with c1=1, c2=1. This is unproblematic since constants
|
||||
# have no usable docstring and won't be documented automatically.
|
||||
if (py_object is not None and
|
||||
not isinstance(py_object, six.integer_types + six.string_types +
|
||||
(six.binary_type, six.text_type, float, complex, bool))
|
||||
and py_object is not ()): # pylint: disable=literal-comparison
|
||||
singelton_types = (
|
||||
six.integer_types + six.string_types +
|
||||
(six.binary_type, six.text_type, float, complex, bool))
|
||||
if (py_object not in (None, ()) and
|
||||
not isinstance(py_object, singelton_types)):
|
||||
object_id = id(py_object)
|
||||
if object_id in reverse_index:
|
||||
master_name = reverse_index[object_id]
|
||||
|
|
Loading…
Reference in New Issue