Turns out the code actually postdates those functions you quote by about two years. Two different authors though, so we may not be the first struggling with the code ;) The mask part does look safe, although I'd like to know what the comment on line 2006 means.

I don't feel very confidence reviewing masked array code, there are a lot of subtleties that I don't understand yet...