wayfair / pylift

Uplift modeling package.
http://pylift.readthedocs.io
BSD 2-Clause "Simplified" License
368 stars 76 forks source link

Fix check of rho argument to sim_pte #38

Open cody-somerville opened 4 years ago

cody-somerville commented 4 years ago

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 commented 4 years ago

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