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

[MXNET-696] Define cmp() in Python 3 again #12295

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Aug 22, 2018

Description

A second attempt at #12191 with no Unicode characters this time...

Fixes #8270 @vandanavk

cmp() was removed in Python 3 so this PR recreates it if required leveraging the formula at http://python-future.org/compatible_idioms.html#cmp

Description

Define cmp() in Python 3

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Define cmp() in Python 3

Comments

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

@marcoabreu #12237 (comment)

@vandanavk
Copy link
Contributor

@piyushghai

Copy link
Contributor

@piyushghai piyushghai left a comment

Choose a reason for hiding this comment

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

LGTM.
Thanks for fixing the pylint issue here.

@@ -29,6 +29,13 @@
import re
from mxnet.test_utils import assert_almost_equal

try:
Copy link
Contributor

Choose a reason for hiding this comment

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

cmp = lambda(x, y): (x > y) - (x < y) could also work with a bit less code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. It is a Python 3 syntax error
  2. With the syntax fixed it generates a PEP8 violation in flake8 https://stackoverflow.com/questions/25010167/e731-do-not-assign-a-lambda-expression-use-a-def

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see. Thanks!

@sandeep-krishnamurthy sandeep-krishnamurthy added the pr-awaiting-testing PR is reviewed and waiting CI build and test label Aug 23, 2018
Copy link
Contributor

@sandeep-krishnamurthy sandeep-krishnamurthy 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 your contributions!
This PR is ready to merge after CI pass.
I have restarted the PR build as it earlier failed with file download transient issue.

@sandeep-krishnamurthy sandeep-krishnamurthy merged commit 4664a30 into apache:master Aug 23, 2018
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-testing PR is reviewed and waiting CI build and test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 undefined names in Python code
5 participants