shouldn't there be a check if any(mask) and if not just return a, None to avoid any custom operations in functions using _replace_nan and comparing against None?