From 20f799cb06b4b9b08a737462f7e0de21abb57e82 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 11 Jan 2020 06:39:04 +0100 Subject: [PATCH] Use ==/!= to compare str, bytes, and int literals (#4686) Identity is not the same thing as equality in Python so use ==/!= to compare str, bytes, and int literals. In Python >= 3.8, these instances will raise __SyntaxWarnings__ so it is best to fix them now. https://docs.python.org/3.8/whatsnew/3.8.html#porting-to-python-3-8 % __python__ ``` >>> dtype = "float" >>> dtype += "16" >>> dtype == "float16" True >>> dtype is "float16" False >>> 0 == 0.0 True >>> 0 is 0.0 False ``` --- tests/python/relay/test_op_level1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/relay/test_op_level1.py b/tests/python/relay/test_op_level1.py index 33c8b90bc7d6a..6723369f3886d 100644 --- a/tests/python/relay/test_op_level1.py +++ b/tests/python/relay/test_op_level1.py @@ -155,7 +155,7 @@ def test_bias_add(): for dtype in ['float16', 'float32']: xshape=(10, 2, 3, 4) bshape=(2,) - rtol = 1e-2 if dtype is 'float16' else 1e-5 + rtol = 1e-2 if dtype == 'float16' else 1e-5 x = relay.var("x", shape=xshape, dtype=dtype) bias = relay.var("bias", dtype=dtype) z = relay.nn.bias_add(x, bias)