LSSTDESC/healsparse

Map ordering in `ufunc_intersection`

Closed this issue · 3 comments

I find that the two maps m_a and m_b below are the same:

m_a = hsp.ufunc_intersection([m2, m1], np.divide, filler_value=1.)
m_b = hsp.ufunc_intersection([m1, m2], np.divide, filler_value=1.)

which shouldn't be the case because a/b != b/a.

This is an interesting case. The problem appears to be because the concept of a "filler value" doesn't really make sense with division; what both are doing in this case is computing 1 / m1 / m2 which is indeed equal to 1 / m2 / m1 (and neither of these is the desired result!).

A way around this is to use multiplication instead of division. In a quick test, this works:

m_a = hsp.product_intersection([m2, m1**-1])
m_b = hsp.product_intersection([m1, m2**-1])

@damonge @erykoff Should I close this issue, or is there any action that we should take to solve it? (I thought we documented this a while ago, but other than that, I'm not sure if we can do anything?)

I think this could be closed.