CH-Earth / pyviscous

PyVISCOUS: Open-Source VISCOUS Code in Python
Other
5 stars 5 forks source link

Why is this float() conversion needed? #9

Closed wknoben closed 1 year ago

wknoben commented 2 years ago

https://github.com/h294liu/pyviscous/blob/cb5aeef7c288ac1383dc4f06678b2b06e7bea5d4/pyviscous/pyviscous.py#L304

h294liu commented 2 years ago

This is to avoid a case where (1) both the numerator and denominator are integer, and (2) Python 2, not 3, is used. A typical example is, 2 / 3 = 0. This is incorrect and is NOT what we want. With float, we can get 2 / 3.0 = 0.6667, which is correct. (reference: https://riptutorial.com/python/example/2797/integer-division)

wknoben commented 2 years ago

Adding this explanation as a comment in the code would be good