numexpr icon indicating copy to clipboard operation
numexpr copied to clipboard

Incorrect result with python % (modulo) operator and integer variable

Open arondaniel opened this issue 3 years ago • 0 comments

Python 3.9.13, numpy 1.23.0, numexpr 2.8.3

Hello and many thanks for a great library.

Using python modulo gives incorrect result if integer variable used w/ modulo operator.

solar = np.array([ -135 ])

Expected:

solar%360 array([225])

Incorrect answer using int variable:

ne.evaluate("solar%360") array([-135], dtype=int64)

Workaround, make left or right side a float:

ne.evaluate("solar%360.") array([225.])

arondaniel avatar Jul 06 '22 18:07 arondaniel