Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

If variable is not used within the loop body, start the name with an underscore #20505

Merged
merged 11 commits into from
Sep 5, 2021

Conversation

mozga-intel
Copy link
Contributor

Description

Loop control variable 'x' is not used within the loop body. If this is intended, start the name with an underscore.

Checklist

Essentials

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@mozga-intel mozga-intel requested a review from szha as a code owner August 9, 2021 12:39
@mxnet-bot
Copy link

Hey @mozga-intel , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [unix-gpu, clang, windows-cpu, unix-cpu, miscellaneous, sanity, centos-cpu, centos-gpu, windows-gpu, edge, website]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress labels Aug 9, 2021
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-work-in-progress PR is still work in progress labels Aug 10, 2021
@mozga-intel
Copy link
Contributor Author

mozga-intel commented Aug 10, 2021

@szha Could you help:

Please have a look at the test: test. There is an axis param that is set up in a loop: [loop] Loop control variable 'axis' not used within the loop body but it's only used out of the loop scope: loop

    for axis in range(-data_ndim, data_ndim):
        data_shape = ()
        for _ in range(data_ndim):
            data_shape += (np.random.randint(low=1, high=5), )
        idx_shape = ()
        for _ in range(idx_ndim):
            idx_shape += (np.random.randint(low=1, high=5), )
     ....
    
    result = mx.sym.take(a=data, indices=idx, axis=axis, mode=mode)

The axis is always equal to data_ndim- 1. Following the documentation doc, the axis of an input array is to be taken. For the input tensor of rank r, it could be in the range of [-r, r-1]. Where r = data_ndim; There is a similar issue: #20508 (Float32 Linlag Cholesky is disabled by default)

Could you please tell whether the lines L4191 to L4231 shouldn't be placed in the loop scope to get a changeable axis?

@mseth10 mseth10 added pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 10, 2021
@mozga-intel
Copy link
Contributor Author

@mxnet-bot run ci [website]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [website]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-work-in-progress PR is still work in progress labels Aug 10, 2021
@mseth10 mseth10 added pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 10, 2021
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 10, 2021
@mozga-intel
Copy link
Contributor Author

@mxnet-bot run ci [centos-gpu]

@mseth10 mseth10 added the pr-awaiting-testing PR is reviewed and waiting CI build and test label Aug 24, 2021
@mseth10 mseth10 added pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress labels Aug 24, 2021
@mozga-intel
Copy link
Contributor Author

@mxnet-bot run ci [centos-gpu, unix-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [unix-gpu, centos-gpu]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 24, 2021
Copy link
Member

@szha szha left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. A few loops can be updated to be more clear.

python/mxnet/gluon/contrib/estimator/estimator.py Outdated Show resolved Hide resolved
python/mxnet/operator.py Outdated Show resolved Hide resolved
python/mxnet/test_utils.py Outdated Show resolved Hide resolved
tests/python/unittest/test_gluon_data.py Outdated Show resolved Hide resolved
tests/python/unittest/test_gluon_data.py Outdated Show resolved Hide resolved
tests/python/unittest/test_numpy_interoperability.py Outdated Show resolved Hide resolved
tests/python/unittest/test_numpy_op.py Outdated Show resolved Hide resolved
tests/python/unittest/test_numpy_op.py Outdated Show resolved Hide resolved
tests/python/unittest/test_numpy_op.py Outdated Show resolved Hide resolved
tests/python/unittest/test_numpy_op.py Outdated Show resolved Hide resolved
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-review PR is waiting for code review pr-awaiting-testing PR is reviewed and waiting CI build and test labels Aug 30, 2021
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Sep 3, 2021
@szha szha merged commit 8c7d5c6 into apache:master Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants