Skip to content

Commit aee7f95

Browse files
yifeiftensorflower-gardener
authored andcommitted
Add C0301 line-too-long error to pylint sanity check.
PiperOrigin-RevId: 183467186
1 parent e955377 commit aee7f95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2184
-1865
lines changed

tensorflow/contrib/bayesflow/python/ops/custom_grad_impl.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
]
3232

3333

34-
def custom_gradient(fx, gx, x, axis=(),
35-
fx_gx_manually_stopped=False,
34+
def custom_gradient(fx, gx, x, axis=(), fx_gx_manually_stopped=False,
3635
name=None):
3736
"""Enables specifying a custom gradient.
3837
@@ -43,7 +42,8 @@ def custom_gradient(fx, gx, x, axis=(),
4342
h(x) = x * stop_gradient(g(x)) + stop_gradient(f(x) - x * g(x))
4443
```
4544
46-
is such that `h(x) = stop_gradient(f(x))` and `grad[h(x), x] = stop_gradient(g(x)).`
45+
is such that `h(x) = stop_gradient(f(x))` and `grad[h(x), x] =
46+
stop_gradient(g(x)).`
4747
4848
In addition to scalar-domain/scalar-range functions, this function also
4949
supports tensor-domain/scalar-range functions. However, in the latter case it

tensorflow/contrib/data/python/kernel_tests/bucketing_test.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def testSimple(self):
4141
dataset_ops.Dataset.from_tensor_slices(components).map(lambda x: x * x)
4242
.apply(
4343
grouping.group_by_window(lambda x: x % 2, lambda _, xs: xs.batch(4),
44-
4))
45-
.make_initializable_iterator())
44+
4)).make_initializable_iterator())
4645
init_op = iterator.initializer
4746
get_next = iterator.get_next()
4847

@@ -53,7 +52,8 @@ def testSimple(self):
5352
while True:
5453
result = sess.run(get_next)
5554
self.assertTrue(
56-
all(x % 2 == 0 for x in result) or all(x % 2 == 1)
55+
all(x % 2 == 0
56+
for x in result) or all(x % 2 == 1)
5757
for x in result)
5858
counts.append(result.shape[0])
5959

@@ -116,8 +116,8 @@ def reduce_func(_, xs):
116116
iterator = (
117117
dataset_ops.Dataset.from_tensor_slices(components)
118118
.map(lambda x: (x, ops.convert_to_tensor([x * x]))).apply(
119-
grouping.group_by_window(lambda x, _: x % 2, reduce_func, 32))
120-
.make_initializable_iterator())
119+
grouping.group_by_window(lambda x, _: x % 2, reduce_func,
120+
32)).make_initializable_iterator())
121121
init_op = iterator.initializer
122122
get_next = iterator.get_next()
123123

@@ -136,7 +136,8 @@ def reduce_func(key, window):
136136
window.padded_batch(
137137
4, padded_shapes=tensor_shape.TensorShape([None])),
138138
window.padded_batch(
139-
4, padded_shapes=ops.convert_to_tensor([(key + 1) * 10])),))
139+
4, padded_shapes=ops.convert_to_tensor([(key + 1) * 10])),
140+
))
140141

141142
iterator = (
142143
dataset_ops.Dataset.from_tensor_slices(components)
@@ -200,9 +201,10 @@ def _dynamicPad(self, bucket, window, window_size):
200201
# dynamically and does not rely on static shape information about
201202
# the arguments.
202203
return dataset_ops.Dataset.zip(
203-
(dataset_ops.Dataset.from_tensors(bucket), window.padded_batch(
204-
32, (tensor_shape.TensorShape([]), tensor_shape.TensorShape([None]),
205-
tensor_shape.TensorShape([3])))))
204+
(dataset_ops.Dataset.from_tensors(bucket),
205+
window.padded_batch(
206+
32, (tensor_shape.TensorShape([]), tensor_shape.TensorShape(
207+
[None]), tensor_shape.TensorShape([3])))))
206208

207209
def testSingleBucket(self):
208210

@@ -307,12 +309,13 @@ def _map_fn(v):
307309

308310
def _dynamic_pad_fn(bucket, window, _):
309311
return dataset_ops.Dataset.zip(
310-
(dataset_ops.Dataset.from_tensors(bucket), window.padded_batch(
311-
32, {
312-
"x": tensor_shape.TensorShape([]),
313-
"y": tensor_shape.TensorShape([None]),
314-
"z": tensor_shape.TensorShape([3])
315-
})))
312+
(dataset_ops.Dataset.from_tensors(bucket),
313+
window.padded_batch(
314+
32, {
315+
"x": tensor_shape.TensorShape([]),
316+
"y": tensor_shape.TensorShape([None]),
317+
"z": tensor_shape.TensorShape([3])
318+
})))
316319

317320
input_dataset = (
318321
dataset_ops.Dataset.from_tensor_slices(math_ops.range(128)).map(_map_fn)

tensorflow/contrib/eager/python/datasets.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,17 @@ def remote_fn(h):
112112
remote_fn.add_to_graph(None)
113113
target = constant_op.constant("/device:CPU:0")
114114
with ops.device(self._device):
115-
self._buffer_resource_handle = prefetching_ops.function_buffering_resource(
115+
self._buffer_resource_handle = prefetching_ops.function_buffering_resource( # pylint: disable=line-too-long
116116
string_arg=iter_string_handle,
117117
f=remote_fn,
118118
target_device=target,
119119
buffer_size=10,
120120
thread_pool_size=1,
121121
container="",
122122
shared_name=_generate_shared_name("function_buffer_resource"))
123-
self._buffer_resource_deleter = resource_variable_ops.EagerResourceDeleter(
124-
handle=self._buffer_resource_handle, handle_device=self._device)
123+
self._buffer_resource_deleter = resource_variable_ops.EagerResourceDeleter( # pylint: disable=line-too-long
124+
handle=self._buffer_resource_handle,
125+
handle_device=self._device)
125126

126127
def __iter__(self):
127128
return self

tensorflow/contrib/framework/python/ops/arg_scope.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
net = layers.conv2d(net, 256, [5, 5], scope='conv2')
5454
```
5555
56-
Example of how to use tf.contrib.framework.add_arg_scope to enable your function to be called within an arg_scope later:
56+
Example of how to use tf.contrib.framework.add_arg_scope to enable your
57+
function to be called within an arg_scope later:
5758
5859
@tf.contrib.framework.add_arg_scope
5960
def conv2d(*args, **kwargs)
@@ -65,11 +66,10 @@ def conv2d(*args, **kwargs)
6566
from tensorflow.python.util import tf_contextlib
6667
from tensorflow.python.util import tf_decorator
6768

68-
__all__ = ['arg_scope',
69-
'add_arg_scope',
70-
'current_arg_scope',
71-
'has_arg_scope',
72-
'arg_scoped_arguments']
69+
__all__ = [
70+
'arg_scope', 'add_arg_scope', 'current_arg_scope', 'has_arg_scope',
71+
'arg_scoped_arguments'
72+
]
7373

7474
_ARGSTACK = [{}]
7575

@@ -172,6 +172,7 @@ def add_arg_scope(func):
172172
Returns:
173173
A tuple with the decorated function func_with_args().
174174
"""
175+
175176
def func_with_args(*args, **kwargs):
176177
current_scope = current_arg_scope()
177178
current_args = kwargs
@@ -180,6 +181,7 @@ def func_with_args(*args, **kwargs):
180181
current_args = current_scope[key_func].copy()
181182
current_args.update(kwargs)
182183
return func(*args, **current_args)
184+
183185
_add_op(func)
184186
setattr(func_with_args, '_key_op', _key_op(func))
185187
return tf_decorator.make_decorator(func, func_with_args)

tensorflow/contrib/fused_conv/python/ops/fused_conv2d_bias_activation_benchmark.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def build_fused_conv_bias_relu_graph(device, input_shape, filter_shape, strides,
116116
for _ in range(1, num_iters):
117117
with ops.control_dependencies([fused_out]):
118118
# pylint: disable=g-line-too-long
119-
fused_out = fused_conv2d_bias_activation_op.fused_conv2d_bias_activation(
119+
fused_out = fused_conv2d_bias_activation_op.fused_conv2d_bias_activation( # pylint: disable=line-too-long
120120
inp,
121121
filt,
122122
bias,
@@ -166,10 +166,10 @@ def _run_graph(self, device, input_shape, filter_shape, strides, padding,
166166
duration = (time.time() - start_time) / num_iters
167167

168168
print("%s inputshape:%s filtershape:%s strides:%s padding:%s "
169-
"%d iters: %.8f sec" %
170-
(device, str(input_shape).replace(" ", ""),
171-
str(filter_shape).replace(" ", ""),
172-
str(strides).replace(" ", ""), padding, num_iters, duration))
169+
"%d iters: %.8f sec" % (device, str(input_shape).replace(" ", ""),
170+
str(filter_shape).replace(" ", ""),
171+
str(strides).replace(" ", ""), padding,
172+
num_iters, duration))
173173
name_template = (
174174
"conv2d_{device}_input_shape_{inputshape}_filter_shape_{filtershape}_"
175175
"strides_{strides}_padding_{padding}")

tensorflow/contrib/image/python/ops/single_image_random_dot_stereograms.py

+19-14
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,29 @@
2626
resource_loader.get_path_to_datafile(
2727
"_single_image_random_dot_stereograms.so"))
2828

29-
def single_image_random_dot_stereograms(
30-
depth_values,
31-
hidden_surface_removal=None,
32-
convergence_dots_size=None,
33-
dots_per_inch=None,
34-
eye_separation=None, mu=None,
35-
normalize=None, normalize_max=None,
36-
normalize_min=None,
37-
border_level=None,
38-
number_colors=None,
39-
output_image_shape=None,
40-
output_data_window=None):
29+
30+
def single_image_random_dot_stereograms(depth_values,
31+
hidden_surface_removal=None,
32+
convergence_dots_size=None,
33+
dots_per_inch=None,
34+
eye_separation=None,
35+
mu=None,
36+
normalize=None,
37+
normalize_max=None,
38+
normalize_min=None,
39+
border_level=None,
40+
number_colors=None,
41+
output_image_shape=None,
42+
output_data_window=None):
4143
"""Output a RandomDotStereogram Tensor for export via encode_PNG/JPG OP.
4244
4345
Given the 2-D tensor 'depth_values' with encoded Z values, this operation
4446
will encode 3-D data into a 2-D image. The output of this Op is suitable
4547
for the encode_PNG/JPG ops. Be careful with image compression as this may
4648
corrupt the encode 3-D data witin the image.
4749
48-
Based upon [this paper](http://www.learningace.com/doc/4331582/b6ab058d1e206d68ab60e4e1ead2fe6e/sirds-paper).
50+
Based upon [this
51+
paper](http://www.learningace.com/doc/4331582/b6ab058d1e206d68ab60e4e1ead2fe6e/sirds-paper).
4952
5053
This outputs a SIRDS image as picture_out.png:
5154
@@ -113,7 +116,8 @@ def single_image_random_dot_stereograms(
113116
hidden_surface_removal=hidden_surface_removal,
114117
convergence_dots_size=convergence_dots_size,
115118
dots_per_inch=dots_per_inch,
116-
eye_separation=eye_separation, mu=mu,
119+
eye_separation=eye_separation,
120+
mu=mu,
117121
normalize=normalize,
118122
normalize_max=normalize_max,
119123
normalize_min=normalize_min,
@@ -123,4 +127,5 @@ def single_image_random_dot_stereograms(
123127
output_data_window=output_data_window)
124128
return result
125129

130+
126131
ops.NotDifferentiable("SingleImageRandomDotStereograms")

tensorflow/contrib/kernel_methods/python/losses_test.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,20 @@ def testZeroLossInt64Labels(self):
119119

120120
def testUnknownShape(self):
121121
"""Result keeps same with `testZeroLossInt32Labels`"""
122-
logits_np = np.array([[1.2, -1.4, -1.0],
123-
[1.4, 1.8, 4.0],
124-
[0.5, 1.8, -1.0]])
122+
logits_np = np.array([[1.2, -1.4, -1.0], [1.4, 1.8, 4.0], [0.5, 1.8, -1.0]])
125123
labels_np = np.array([0, 2, 1], dtype=np.int32)
126124

127-
logits_shapes = [[3, 3], # batch_size, num_classes
128-
[None, 3],
129-
[3, None],
130-
[None, None]]
125+
logits_shapes = [
126+
[3, 3], # batch_size, num_classes
127+
[None, 3],
128+
[3, None],
129+
[None, None]
130+
]
131131

132132
for batch_size, num_classes in logits_shapes:
133133
with self.test_session():
134-
logits = array_ops.placeholder(dtypes.float32, shape=(batch_size, num_classes))
134+
logits = array_ops.placeholder(
135+
dtypes.float32, shape=(batch_size, num_classes))
135136
labels = array_ops.placeholder(dtypes.int32, shape=(batch_size,))
136137
loss = losses.sparse_multiclass_hinge_loss(labels, logits)
137138
result = loss.eval(feed_dict={logits: logits_np, labels: labels_np})

0 commit comments

Comments
 (0)