Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert always evaluates to True #29

Open
shivakanthsujit opened this issue Jul 12, 2022 · 0 comments
Open

Assert always evaluates to True #29

shivakanthsujit opened this issue Jul 12, 2022 · 0 comments

Comments

@shivakanthsujit
Copy link

In these lines, because the assert statement is broken into multiple lines and hence covered with parentheses, the assert evaluates the tuple itself. So it will always evaluate to True.

assert (loss_fn is not None or grads is not None,
'Either a loss function or grads must be specified.')

assert (has_aux,
'When grads are provided, expects no aux outputs.')

This can be fixed by changing it to

assert loss_fn is not None or grads is not None, \
                'Either a loss function or grads must be specified.'

assert has_aux, \
                    'When grads are provided, expects no aux outputs.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant