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 #3992

Merged
merged 6 commits into from
Jun 22, 2022
Merged

Fix Python formatting #3992

merged 6 commits into from
Jun 22, 2022

Conversation

szalpal
Copy link
Member

@szalpal szalpal commented Jun 17, 2022

Category:

Refactoring (Redesign of existing code that doesn't affect functionality)

Description:

Fix Python formatting.

TODO:

  • Run L1 tests, in the final CI check (after the review approval)

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: N/A

Signed-off-by: szalpal <mszolucha@nvidia.com>
Signed-off-by: szalpal <mszolucha@nvidia.com>
Signed-off-by: szalpal <mszolucha@nvidia.com>
@szalpal
Copy link
Member Author

szalpal commented Jun 17, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5111600]: BUILD STARTED

Signed-off-by: szalpal <mszolucha@nvidia.com>
@szalpal szalpal marked this pull request as ready for review June 17, 2022 14:15
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5111600]: BUILD PASSED

@szalpal
Copy link
Member Author

szalpal commented Jun 19, 2022

L1 tests pass

Signed-off-by: szalpal <mszolucha@nvidia.com>
@@ -33,20 +29,15 @@ def get_min_shape_helper(batch, max_shape):
`batch` can also be a string "dataset" that indicates we passed a Dataset object as input
without specifying the batch mode through: Input(dataset, batch=...)
"""
if batch is None or batch == True:
if batch is None or batch == True: # noqa: E712
Copy link
Member

Choose a reason for hiding this comment

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

I think is True would be fine here (1. would not change how the function works on actual inputs and 2. would not trigger the linter)

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

@@ -143,36 +134,38 @@ def to_dataset(pipeline_desc, device_str):

with tf.device('/cpu:0'):
input_dataset = tf.data.Dataset.from_tensors(tensor).repeat()
if batch is None or batch == True:
if batch is None or batch == True: # noqa: E712
Copy link
Member

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

@@ -184,50 +177,46 @@ def to_dataset(pipeline_desc, device_str):
tf_type = tf.dtypes.as_dtype(dtype)
input_dataset = tf.data.Dataset.from_generator(
input_iterator, output_types=tf_type, output_shapes=out_shape, args=_args)
if batch is None or batch == True:
if batch is None or batch == True: # noqa: E712
Copy link
Member

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

if batch is None or batch == True:
InfiniteSampleIterator, output_types=tf_type, output_shapes=shape,
args=(value,))
if batch is None or batch == True: # noqa: E712
Copy link
Member

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



def test_numba_func_cpu():
def set_all_values_to_255_batch(out0, in0):
out0[0][:] = 255

def setup_out_shape(out_shape, in_shape):
out_shape = in_shape
out_shape = in_shape # noqa: F841
Copy link
Member

Choose a reason for hiding this comment

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

It may be out of scope, but this assignment does seem to do nothing indeed. I wonder if the intention was more like out_shape[i] = in_shape[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.

Changed to pass, as this is a no-op statement.

@@ -72,11 +70,13 @@ def _compare_to_cv_distortion(in_img, out_img, q, no):
decoded_img = cv2.cvtColor(decoded_img_bgr, cv2.COLOR_BGR2RGB)

diff = cv2.absdiff(out_img, decoded_img)
diff_in_range = np.average(diff) < 5, f"Absolute difference with the reference is too big: {np.average(diff)}"
diff_in_range = np.average(
diff) < 5, f"Absolute difference with the reference is too big: {np.average(diff)}"
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this piece of code broken?

diff_in_range is a pair, thus it is always true-ish and the assert never fails and does not actually enforce the np.average(diff) < 5 condition.

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 string after comma looks like some leftover from assert being there previously. Got rid of the string.

Signed-off-by: szalpal <mszolucha@nvidia.com>
@szalpal
Copy link
Member Author

szalpal commented Jun 21, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5138994]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5138994]: BUILD PASSED

@szalpal
Copy link
Member Author

szalpal commented Jun 22, 2022

L1 tests pass

@szalpal szalpal merged commit 15cf484 into NVIDIA:main Jun 22, 2022
@szalpal szalpal deleted the fix_python_2 branch February 9, 2024 00:25
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

4 participants