returnn icon indicating copy to clipboard operation
returnn copied to clipboard

fix SyntaxWarning

Open vieting opened this issue 3 years ago • 2 comments

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.

vieting avatar Feb 17 '22 14:02 vieting

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?

vieting avatar Feb 17 '22 15:02 vieting

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.

albertz avatar Feb 17 '22 15:02 albertz