returnn
returnn copied to clipboard
fix SyntaxWarning
When running RETURNN, I get
/.../returnn/returnn/tf/network.py:1621: SyntaxWarning: "is" with a literal. Did you mean "=="?
if loss is 0:
/.../returnn/returnn/tf/util/basic.py:2024: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if dim is not 1:
/.../returnn/returnn/tf/util/basic.py:5550: SyntaxWarning: "is" with a literal. Did you mean "=="?
if start is 0 and stop is None:
/.../returnn/returnn/tf/layers/base.py:1383: SyntaxWarning: "is" with a literal. Did you mean "=="?
if c is 0:
I don't see a reason to do it the way it is currently done, so we could just fix it like proposed here.
It's not as simple (that's why I did not do it yet).
Basically you need
isinstance(c, (int, float, numpy.number))or so.
I see. It seems that all tests pass though, so it's maybe difficult to tell what would be correct and doesn't break any setups, right?
But still it should be done like that. This just shows that the tests don't cover this. I wonder actually, I thought e.g. loss should always become a tf.Tensor.