Open stress-tess opened 1 year ago
wow, so these only differ in one spot. Index 36
Numpy has -67
and arkouda has -66
The fraction represented by the linspace at position 36 is -6/11
, so this ends up being 36 // (-6/11)
which seems like it would divide evenly to 66, but the floor division gives 67. Python and numpy agree on this
>>> 36 / (-6/11)
-66.0
>>> 36 // (-6/11)
-67.0
>>> 36 // ak.array([-0.5454545454545454])
array([-66])
So it makes sense we are getting this wrong because we do https://github.com/Bears-R-Us/arkouda/blob/e574712ed9058f4ef51549aba06748c8de0bee4c/src/BinOp.chpl#L29
This seems to be a numeric precision issue when dividing by an infinite decimal. I found this much simpler example which shows this:
>>> 1 // (-1/3)
-4.0
>>> 1 / (-1/3)
-3.0
I guess we just need to figure out what the c function used for integer division and use that
So according to this stack overflow answer, it's not really floor divide but round towards zero. I'm hoping updating the one line to be trunc(numerator/denom);
will do the trick
While working #2688, I updated the float array to include negatives which resulted in the following value mismatch with numpy. I don't see the mismatch at a glance, but I'll dig into it more after all the tests are converted