Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.

Conversation

@cody-somerville
Copy link

The expression to check if the rho argument to sim_pte is between 0 and 1 used the bitwise OR operator instead of the logical OR operator. Due to operator precedence of the bitwise OR operator, the bitwise operator is evaluated first before the comparisons. '0 | rho' will evaluate to the value of rho, given rho is an integer, making the conditional equivalently rho < rho > 1 which will always evaluate to False no matter the value of rho. If rho is a float, which would be common, a TypeError exception would be thrown as you can't perform bitwise OR on a float. To correctly check that rho is between 0 and 1, the bitwise OR operator is replaced with the logical OR operator 'or'.

The expression to check if the rho argument to sim_pte is between 0 and 1 used the bitwise OR operator instead of the logical OR operator. Due to operator precedence of the bitwise OR operator, the bitwise operator is evaluated first before the comparisons.  '0 | rho' will evaluate to the value of rho, given rho is an integer, making the conditional equivalently rho < rho > 1 which will always evaluate to False no matter the value of rho. If rho is a float, which would be common, a TypeError exception would be thrown as you can't perform bitwise OR on a float. To correctly check that rho is between 0 and 1, the bitwise OR operator is replaced with the logical OR operator 'or'.
@cody-somerville
Copy link
Author

@rsyi This change may interest you for your pylift/pylift fork.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant