stsievert/swix

intersection gives incorrect output

Closed this issue · 1 comments

var a = array(1, 2, 3, 4)
var b = array(1, 2, 3, 4)
var c = intersection(a, b)
print(c) // array([])

This is obviously wrong and was pointed out by @srambhatla while working on a different project that incorporates swix.

Closed! Turns out in in1d I had

let (xx, yy) = meshgrid(x, y: 
let i = abs(xx-yy) < S2_THRESHOLD
let j = (sum(i, axis:1)) > 0.5
return 1-j

instead of

let (xx, yy) = meshgrid(x, y: 
let i = abs(xx-yy) < S2_THRESHOLD
let j = (sum(i, axis:1)) > 0.5
return 0+j

which is flips all the binary values!