You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by sk...@apache.org on 2018/08/17 15:41:41 UTC

[incubator-mxnet] branch master updated: [MXNET-696] Define cmp() in Python 3 for line 222 (#12191)

This is an automated email from the ASF dual-hosted git repository.

skm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 54ed3e5  [MXNET-696] Define cmp() in Python 3 for line 222 (#12191)
54ed3e5 is described below

commit 54ed3e5d95b997bf1957b4e5cd7f117894ed4a19
Author: cclauss <cc...@bluewin.ch>
AuthorDate: Fri Aug 17 17:41:34 2018 +0200

    [MXNET-696] Define cmp() in Python 3 for line 222 (#12191)
    
    * Define cmp() in Python 3 for line 222
    
    [__cmp()__ was removed in Python 3](https://docs.python.org/3/whatsnew/3.0.html#ordering-comparisons) so this PR recreates it if required leveraging the formula at http://python-future.org/compatible_idioms.html#cmp
    
    * Add URL in the comments
    
    * Force a retest
    
    * Remove trailing whitespace
---
 tests/nightly/model_backwards_compatibility_check/common.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/nightly/model_backwards_compatibility_check/common.py b/tests/nightly/model_backwards_compatibility_check/common.py
index 8950a92..c41b11f 100644
--- a/tests/nightly/model_backwards_compatibility_check/common.py
+++ b/tests/nightly/model_backwards_compatibility_check/common.py
@@ -29,6 +29,13 @@ from mxnet.gluon import nn
 import re
 from mxnet.test_utils import assert_almost_equal
 
+try:
+    cmp             # Python 2
+except NameError:
+    # See: https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
+    def cmp(x, y):  # Python 3
+        return (x > y) - (x < y)
+
 # Set fixed random seeds.
 mx.random.seed(7)
 np.random.seed(7)