Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python formatting #3988

Merged
merged 16 commits into from
Jun 21, 2022
Merged

Fix Python formatting #3988

merged 16 commits into from
Jun 21, 2022

Conversation

stiepan
Copy link
Member

@stiepan stiepan commented Jun 15, 2022

Category:

Other (e.g. Documentation, Tests, Configuration)

Description:

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: DALI-2823

@stiepan
Copy link
Member Author

stiepan commented Jun 15, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5089788]: BUILD STARTED

@@ -166,7 +172,9 @@ def define_graph(self):

def test_multiple_input_valid_shapes():
for batch in [1, 10]:
for shapes in [None, (None, None), ((batch, 200, 200, 3), None), (None, (batch, 1)), (None, (batch,))]:
for shapes in [
None, (None, None), ((batch, 200, 200, 3), None), (None, (batch, 1)), (None, (batch,))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, given the number of commas and braces:

Suggested change
None, (None, None), ((batch, 200, 200, 3), None), (None, (batch, 1)), (None, (batch,))
None,
(None, None),
((batch, 200, 200, 3), None),
(None, (batch, 1)),
(None, (batch,))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

for shape in [(None, None, None, None), (None, None, 2), (batch, None, None, None),
(batch, None, 2)]:
for shape in [
(None, None, None, None), (None, None, 2), (batch, None, None, None), (batch, None, 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(None, None, None, None), (None, None, 2), (batch, None, None, None), (batch, None, 2)
(None, None, None, None),
(None, None, 2),
(batch, None, None, None),
(batch, None, 2)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 338 to 339
yield raises(TypeError, expected_msg)(dali_pipe_deprecated), {"shapes": 2}, 2, tf.uint8, \
dali_types.UINT8, 1, 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
yield raises(TypeError, expected_msg)(dali_pipe_deprecated), {"shapes": 2}, 2, tf.uint8, \
dali_types.UINT8, 1, 2
yield raises(TypeError, expected_msg)(dali_pipe_deprecated), \
{"shapes": 2}, 2, tf.uint8, dali_types.UINT8, 1, 2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 237 to 238
data = generate_data(31, 13, custom_shape_generator(3, 7, 160, 200, 80, 100, 3, 3), lo=0,
hi=255, dtype=np.uint8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = generate_data(31, 13, custom_shape_generator(3, 7, 160, 200, 80, 100, 3, 3), lo=0,
hi=255, dtype=np.uint8)
data = generate_data(31, 13, custom_shape_generator(3, 7, 160, 200, 80, 100, 3, 3),
lo=0, hi=255, dtype=np.uint8)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5089788]: BUILD FAILED

Comment on lines 318 to 319
'batch_processing': True, 'devices': ['cpu'], 'in_types': [types.UINT8],
'ins_ndim': [3], 'out_types': [types.UINT8], 'outs_ndim': [3],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'batch_processing': True, 'devices': ['cpu'], 'in_types': [types.UINT8],
'ins_ndim': [3], 'out_types': [types.UINT8], 'outs_ndim': [3],
'batch_processing': True, 'devices': ['cpu'],
'in_types': [types.UINT8], 'ins_ndim': [3],
'out_types': [types.UINT8], 'outs_ndim': [3],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 323 to 324
'batch_processing': False, 'devices': ['cpu'], 'in_types': [types.UINT8],
'ins_ndim': [3], 'out_types': [types.UINT8], 'outs_ndim': [3],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'batch_processing': False, 'devices': ['cpu'], 'in_types': [types.UINT8],
'ins_ndim': [3], 'out_types': [types.UINT8], 'outs_ndim': [3],
'batch_processing': False, 'devices': ['cpu'],
'in_types': [types.UINT8], 'ins_ndim': [3],
'out_types': [types.UINT8], 'outs_ndim': [3],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 202 to 216
rois = [
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50), (4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0),
0),
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50), (4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0),
-1),
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50), (4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0),
(118, 186, 0)),
("HWC", (60, 80, 3), "HW", (4, 2, 3, 4), (50, 10, 10, 50),
(4 / 60.0, 2 / 80.0, 3 / 60.0, 4 / 80.0), (50 / 60.0, 10 / 80.0, 10 / 60.0, 50 / 80.0), 0),
("HWC", (60, 80, 3), "H", (4, ), (7, ), (4 / 60.0, ), (7 / 60.0, ), 0),
("DHWC", (10, 60, 80, 3), "DHW", (2, 4, 10), (5, 40, 50), (2 / 10.0, 4 / 60.0, 10 / 80.0),
(5 / 10.0, 40 / 60.0, 50 / 80.0), 0),
("HWC", (60, 80, 1), "WH", (10, 4), (50, 40), (10 / 80.0, 4 / 60.0), (50 / 80.0, 40 / 60.0),
0),
("XYZ", (60, 80, 3), "X", (4, ), (7, ), (4 / 60.0, ), (7 / 60.0, ), -10),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is terrible - I'd recommend reverting and adding #noqa or formatting by hand, e.g:

Suggested change
rois = [
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50), (4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0),
0),
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50), (4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0),
-1),
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50), (4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0),
(118, 186, 0)),
("HWC", (60, 80, 3), "HW", (4, 2, 3, 4), (50, 10, 10, 50),
(4 / 60.0, 2 / 80.0, 3 / 60.0, 4 / 80.0), (50 / 60.0, 10 / 80.0, 10 / 60.0, 50 / 80.0), 0),
("HWC", (60, 80, 3), "H", (4, ), (7, ), (4 / 60.0, ), (7 / 60.0, ), 0),
("DHWC", (10, 60, 80, 3), "DHW", (2, 4, 10), (5, 40, 50), (2 / 10.0, 4 / 60.0, 10 / 80.0),
(5 / 10.0, 40 / 60.0, 50 / 80.0), 0),
("HWC", (60, 80, 1), "WH", (10, 4), (50, 40), (10 / 80.0, 4 / 60.0), (50 / 80.0, 40 / 60.0),
0),
("XYZ", (60, 80, 3), "X", (4, ), (7, ), (4 / 60.0, ), (7 / 60.0, ), -10),
rois = [
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50),
(4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0), 0),
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50),
(4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0), -1),
("HWC", (60, 80, 3), "HW", (4, 10), (40, 50),
(4 / 60.0, 10 / 80.0), (40 / 60.0, 50 / 80.0), (118, 186, 0)),
("HWC", (60, 80, 3), "HW", (4, 2, 3, 4), (50, 10, 10, 50),
(4 / 60.0, 2 / 80.0, 3 / 60.0, 4 / 80.0), (50 / 60.0, 10 / 80.0, 10 / 60.0, 50 / 80.0), 0),
("HWC", (60, 80, 3), "H", (4, ), (7, ), (4 / 60.0, ), (7 / 60.0, ), 0),
("DHWC", (10, 60, 80, 3), "DHW", (2, 4, 10), (5, 40, 50),
(2 / 10.0, 4 / 60.0, 10 / 80.0), (5 / 10.0, 40 / 60.0, 50 / 80.0), 0),
("HWC", (60, 80, 1), "WH", (10, 4), (50, 40),
(10 / 80.0, 4 / 60.0), (50 / 80.0, 40 / 60.0), 0),
("XYZ", (60, 80, 3), "X", (4, ), (7, ), (4 / 60.0, ), (7 / 60.0, ), -10),

Comment on lines 221 to 222
for (input_layout, input_shape, axis_names, anchor, shape, anchor_norm,
shape_norm, fill_value) in rois:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (input_layout, input_shape, axis_names, anchor, shape, anchor_norm,
shape_norm, fill_value) in rois:
for (input_layout, input_shape, axis_names, anchor, shape,
anchor_norm, shape_norm, fill_value) in rois:

Comment on lines 232 to 233
input_shape, anchor, shape, axis_names, input_layout, anchor_norm_arg, \
shape_norm_arg, normalized_anchor, normalized_shape
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input_shape, anchor, shape, axis_names, input_layout, anchor_norm_arg, \
shape_norm_arg, normalized_anchor, normalized_shape
input_shape, anchor, shape, axis_names, input_layout,
anchor_norm_arg, shape_norm_arg, normalized_anchor, normalized_shape

Comment on lines 248 to 249
yield check_operator_erase_with_normalized_coords, device, batch_size, input_shape, anchor_arg,\
shape_arg, axis_names, input_layout, anchor_norm_arg, shape_norm_arg, True, True
Copy link
Contributor

@mzient mzient Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
yield check_operator_erase_with_normalized_coords, device, batch_size, input_shape, anchor_arg,\
shape_arg, axis_names, input_layout, anchor_norm_arg, shape_norm_arg, True, True
yield (check_operator_erase_with_normalized_coords,
device,
batch_size,
input_shape,
anchor_arg,
shape_arg,
axis_names,
input_layout,
anchor_norm_arg,
shape_norm_arg,
True,
True)

or

Suggested change
yield check_operator_erase_with_normalized_coords, device, batch_size, input_shape, anchor_arg,\
shape_arg, axis_names, input_layout, anchor_norm_arg, shape_norm_arg, True, True
yield (check_operator_erase_with_normalized_coords,
device, batch_size,
input_shape,
anchor_arg, shape_arg,
axis_names, input_layout,
anchor_norm_arg, shape_norm_arg,
True, True)

Comment on lines 70 to 72
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])
Copy link
Contributor

@mzient mzient Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that be ok? I wanted this to be aligned in columns.

Suggested change
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])

Comment on lines 102 to 104
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])

@@ -82,108 +84,110 @@ def test_cuda_array_interface_tensor_gpu():
pipe.build()
tensor_list = pipe.run()[0]
assert tensor_list[0].__cuda_array_interface__['data'][0] == tensor_list[0].data_ptr()
assert tensor_list[0].__cuda_array_interface__['data'][1] == True
assert tensor_list[0].__cuda_array_interface__['data'][1] is True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert tensor_list[0].__cuda_array_interface__['data'][1] is True
assert tensor_list[0].__cuda_array_interface__['data'][1]

Copy link
Member Author

@stiepan stiepan Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, the 'data' is expected to be a tuple of integer and boolean, so when choosing on how to fix I leant to a check that does not rely on implicit conversion to bool

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

exclude = re.compile(exclude)
methods = [x for x in methods if not exclude.match(x)]
# we are fine with covering more we can easily list, like numba
assert set(methods).difference(set(tested_methods)) == set(), "Test doesn't cover:\n {}".format(set(methods) - set(tested_methods))
assert set(methods).difference(set(tested_methods)) == set(), "Test doesn't cover:\n {}".format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be personal preference. I'd have broken the line before the string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 244 to 246
anchor_norm_arg = (
4 / 60.0, 10 / 80.0, 2000, 2000, 10 / 60.0, 4 / 80.0
) # second region is completely out of bounds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference: I'd put the comment in the previous line and keep the tuple definition in one line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 137 to 150
for dct_type, norm, axis, n_mfcc, lifter, shape, msg in [
# DCT-I ortho-normalization is not supported
(1, True, 0, 20, 0.0, (100, 100),
"Ortho-normalization is not supported for DCT type I"),
# axis out of bounds
(2, False, -1, 20, 0.0, (100, 100), "Provided axis cannot be negative"),
# axis out of bounds
(2, False, 2, 20, 0.0, (100, 100), "Axis [\\d]+ is out of bounds \\[[\\d]+,[\\d]+\\)"),
# not supported DCT type
(10, False, 0, 20, 0.0, (100, 100),
"Unsupported DCT type: 10. Supported types are: 1, 2, 3, 4"),
]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd aim for some consistency here (e.g. move the error message to the next line always)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

assert(True)
except BaseException:
assert(False)
lazy_pipe.build()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing assert_raises here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example above had different order of asserts, I think this one was meant to simply pass (as opposed to the one above that should raise).

Comment on lines 1227 to 1229
out1 = as_cpu(out[0]).at(i)
out2 = as_cpu(out[1]).at(i)
out3 = as_cpu(out[2]).at(i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider test_utils.as_array(out[0][i]). You wouldn't need as_cpu

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

out1 = out[0].as_cpu().at(i) if isinstance(out[0][0], dali.backend_impl.TensorGPU) else out[0].at(i)
out2 = out[1].as_cpu().at(i) if isinstance(out[1][0], dali.backend_impl.TensorGPU) else out[1].at(i)
out3 = out[2].as_cpu().at(i) if isinstance(out[2][0], dali.backend_impl.TensorGPU) else out[2].at(i)
out1 = as_cpu(out[0]).at(i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider test_utils.as_array

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -1656,42 +1701,42 @@ def test_preserve_arg():
pipe = dali.Pipeline(1, 1, 0)
with pipe:
out = dali.fn.external_source(source=[[np.array([-0.5, 1.25])]], preserve=True)
res = dali.fn.resize(out, preserve=True)
res = dali.fn.resize(out, preserve=True) # noqa: F841
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity. What's the problem here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, maybe it is silly: the test checks preservation of unused operators if preserve is set to True. So the linter complains about unused variable. I could very well just call resize and not assign the result to any variable, but wanted to preserve this more "canonical" look of defining the pipeline, after all the variable is unused intentionally.

Comment on lines +1727 to +1726
assert pipe.exec_pipelined is True
assert pipe.exec_async is True
assert pipe.set_affinity is True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert pipe.exec_pipelined is True
assert pipe.exec_async is True
assert pipe.set_affinity is True
assert pipe.exec_pipelined is True
assert pipe.exec_async is True
assert pipe.set_affinity is True
Suggested change
assert pipe.exec_pipelined is True
assert pipe.exec_async is True
assert pipe.set_affinity is True
assert pipe.exec_pipelined
assert pipe.exec_async
assert pipe.set_affinity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I wanted this check to enforce the type of the attribute (to be boolean). I can't be sure that it was an initial intention of the author, but explicit comparison to True literal here made me think so. And it is an attribute of the object we define, so maybe we should test that its type does not unexpectedly change from boolean to something that is accidentally true-ish.

assert pipe.max_streams == -1
assert pipe.prefetch_queue_depth == {"cpu_size": 3, "gpu_size": 2}
assert pipe.cpu_queue_size == 3
assert pipe.gpu_queue_size == 2
assert pipe.py_num_workers == 3
assert pipe.py_start_method == "fork"
assert pipe.enable_memory_stats == False
assert pipe.enable_memory_stats is False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert pipe.enable_memory_stats is False
assert not pipe.enable_memory_stats

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern as above.

Comment on lines 668 to 670
bboxes = [
np.random.random(size=test_box_shape).astype(dtype=np.float32)
for _ in range(batch_size)]
Copy link
Contributor

@mzient mzient Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it reads better that an opening brace on a new line is matched with a closing brace on its own line:

Suggested change
bboxes = [
np.random.random(size=test_box_shape).astype(dtype=np.float32)
for _ in range(batch_size)]
bboxes = [
np.random.random(size=test_box_shape).astype(dtype=np.float32)
for _ in range(batch_size)
]

TBH, I don't even know if the standard allows this.
This should be legal and within length limit:

Suggested change
bboxes = [
np.random.random(size=test_box_shape).astype(dtype=np.float32)
for _ in range(batch_size)]
bboxes = [np.random.random(size=test_box_shape).astype(dtype=np.float32)
for _ in range(batch_size)]

Anyway, these are just suggestions - I won't push it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's weird personal preference: line break on opening of list comprehension leaves a whole line for the expression inside and highlights it nicely, while there is no similar reason for doing so with the closing bracket. Contrary, it weirdly separates the whole comprehension from the block of code it rests in. Anyway, here it perfectly fits with no break, so I reverted the change.

Comment on lines 723 to 731
data = [
np.random.randint(0, 255, size=test_data_shape, dtype=np.uint8)
for _ in range(batch_size)]
bboxes = [
np.random.random(size=test_box_shape).astype(dtype=np.float32)
for _ in range(batch_size)]
labels = [
np.random.randint(0, 255, size=test_lables_shape, dtype=np.int32)
for _ in range(batch_size)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and here, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 696 to 701
bboxes = [
np.random.random(size=test_box_shape).astype(dtype=np.float32)
for _ in range(batch_size)]
labels = [
np.random.randint(0, 255, size=test_lables_shape, dtype=np.int32)
for _ in range(batch_size)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...likewise...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 53 to 55
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9,10,11,12]]))
[9, 10, 11, 12]]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep column alignment?

Suggested change
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9,10,11,12]]))
[9, 10, 11, 12]]))
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]]))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 461 to 468
(fn.random.uniform(range=(0, 2), shape=(2, ), dtype=types.INT32), None,
fn.random.uniform(range=(7, 10), shape=(2, ),
dtype=types.INT32), None, None, None, (0, 1), None),
(fn.random.uniform(range=(0, 2), shape=(1, ), dtype=types.INT32), None,
fn.random.uniform(range=(7, 10), shape=(1, ),
dtype=types.INT32), None, None, None, (1, ), None),
(None, fn.random.uniform(range=(0.0, 0.2), shape=(1, )), None,
fn.random.uniform(range=(0.8, 1.0), shape=(1, )), None, None, (1, ), None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(fn.random.uniform(range=(0, 2), shape=(2, ), dtype=types.INT32), None,
fn.random.uniform(range=(7, 10), shape=(2, ),
dtype=types.INT32), None, None, None, (0, 1), None),
(fn.random.uniform(range=(0, 2), shape=(1, ), dtype=types.INT32), None,
fn.random.uniform(range=(7, 10), shape=(1, ),
dtype=types.INT32), None, None, None, (1, ), None),
(None, fn.random.uniform(range=(0.0, 0.2), shape=(1, )), None,
fn.random.uniform(range=(0.8, 1.0), shape=(1, )), None, None, (1, ), None),
(fn.random.uniform(range=(0, 2), shape=(2, ), dtype=types.INT32), None,
fn.random.uniform(range=(7, 10), shape=(2, ), dtype=types.INT32),
None, None, None, (0, 1), None),
(fn.random.uniform(range=(0, 2), shape=(1, ), dtype=types.INT32), None,
fn.random.uniform(range=(7, 10), shape=(1, ), dtype=types.INT32),
None, None, None, (1, ), None),
(None, fn.random.uniform(range=(0.0, 0.2), shape=(1, )), None,
fn.random.uniform(range=(0.8, 1.0), shape=(1, )), None, None, (1, ), None),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 499 to 505
def _testimpl_numpy_reader_roi_error(file_root, batch_size, ndim, dtype, device,
fortran_order=False, file_filter="*.npy", roi_start=None,
rel_roi_start=None, roi_end=None, rel_roi_end=None,
roi_shape=None, rel_roi_shape=None, roi_axes=None,
out_of_bounds_policy=None, fill_value=None):
Copy link
Contributor

@mzient mzient Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _testimpl_numpy_reader_roi_error(file_root, batch_size, ndim, dtype, device,
fortran_order=False, file_filter="*.npy", roi_start=None,
rel_roi_start=None, roi_end=None, rel_roi_end=None,
roi_shape=None, rel_roi_shape=None, roi_axes=None,
out_of_bounds_policy=None, fill_value=None):
def _testimpl_numpy_reader_roi_error(file_root, batch_size, ndim, dtype, device,
fortran_order=False, file_filter="*.npy",
roi_start=None, rel_roi_start=None,
roi_end=None, rel_roi_end=None,
roi_shape=None, rel_roi_shape=None,
roi_axes=None,
out_of_bounds_policy=None, fill_value=None):

...or just put each one in a separate line

@@ -47,7 +45,7 @@ def __init__(self, data_type):
super().__init__(data_type)
self._data = [
[
np.array([ 1, 2, 3, 4], dtype=self._data_type),
np.array([1, 2, 3, 4], dtype=self._data_type),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
np.array([1, 2, 3, 4], dtype=self._data_type),
np.array([ 1, 2, 3, 4], dtype=self._data_type),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter complains about leading space after [. I decided on aligning the remaining columns to the right while leaving the first one aligned to the left.

np.array([[ 13, 23, 22], [ 23, 21, 14]], dtype=self._data_type),
np.array([[ 23, 3, 6], [ 7, 0, 20]], dtype=self._data_type)
np.array([[13, 23, 22], [23, 21, 14]], dtype=self._data_type),
np.array([[23, 3, 6], [7, 0, 20]], dtype=self._data_type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
np.array([[23, 3, 6], [7, 0, 20]], dtype=self._data_type)
np.array([[23, 3, 6], [ 7, 0, 20]], dtype=self._data_type)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Comment on lines 194 to 195
np.uint8, np.int8, np.uint16, np.int16, np.uint32, np.int32,
np.uint64, np.int64, np.float32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we're at it....

Suggested change
np.uint8, np.int8, np.uint16, np.int16, np.uint32, np.int32,
np.uint64, np.int64, np.float32
np.uint8, np.int8,
np.uint16, np.int16,
np.uint32, np.int32,
np.uint64, np.int64,
np.float32

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 296 to 297
np.uint8, np.int8, np.uint16, np.int16, np.uint32, np.int32,
np.uint64, np.int64, np.float32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
np.uint8, np.int8, np.uint16, np.int16, np.uint32, np.int32,
np.uint64, np.int64, np.float32
np.uint8, np.int8,
np.uint16, np.int16,
np.uint32, np.int32,
np.uint64, np.int64,
np.float32

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 973 to 976
for reader_type in {
"readers.MXNet", "readers.Caffe", "readers.Caffe2", "readers.File", "readers.TFRecord",
"readers.Webdataset"
}:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 984 to 986
for reader_type in {
"readers.MXNet", "readers.Caffe", "readers.Caffe2", "readers.File", "readers.Webdataset"
}:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 1220 to 1222
out1 = as_array(out[0].at(i))
out2 = as_array(out[1].at(i))
out3 = as_array(out[2].at(i))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using as_array, you should use out[0][i]

Suggested change
out1 = as_array(out[0].at(i))
out2 = as_array(out[1].at(i))
out3 = as_array(out[2].at(i))
out1 = as_array(out[0][i])
out2 = as_array(out[1][i])
out3 = as_array(out[2][i])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks!

Comment on lines 1249 to 1251
out1 = as_array(out[0].at(i))
out2 = as_array(out[1].at(i))
out3 = as_array(out[2].at(i))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
out1 = as_array(out[0].at(i))
out2 = as_array(out[1].at(i))
out3 = as_array(out[2].at(i))
out1 = as_array(out[0][i])
out2 = as_array(out[1][i])
out3 = as_array(out[2][i])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 81 to 83
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally, numbers are aligned to the right or to the decimal point.

Suggested change
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]]))
[[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]]))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 102 to 104
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])
ref = np.array([[1, 2, 3, 4, 13, 14, 15],
[5, 6, 7, 8, 16, 17, 18],
[9, 10, 11, 12, 19, 20, 21]])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 53 to 54
sequence_length=sequence_length, shard_id=0,
num_shards=num_shards, random_shuffle=shuffle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sequence_length=sequence_length, shard_id=0,
num_shards=num_shards, random_shuffle=shuffle,
sequence_length=sequence_length,
shard_id=0, num_shards=num_shards,
random_shuffle=shuffle,

...or just go with 1 argument per line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
@stiepan stiepan force-pushed the fix_python_lint_isses_2823 branch from b6eca99 to 43fcc80 Compare June 21, 2022 11:32
@stiepan
Copy link
Member Author

stiepan commented Jun 21, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5137810]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5137810]: BUILD PASSED

@stiepan stiepan merged commit 8c06d53 into NVIDIA:main Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants