def nan_dot(A, B):
 should_be_nan_1 = np.dot(np.isnan(A), (B != 0))
 should_be_nan_2 = np.dot((A != 0), np.isnan(B))
 should_be_nan = (should_be_nan_1 + should_be_nan_2)
 C = np.dot(np.nan_to_num(A), np.nan_to_num(B))
 C[should_be_nan] = np.nan
 return C

def nan_dot ( A , B ) : should_be_nan_1 = np . dot ( np . isnan ( A ) , ( B != 0 ) ) should_be_nan_2 = np . dot ( ( A != 0 ) , np . isnan ( B ) ) should_be_nan = ( should_be_nan_1 + should_be_nan_2 ) C = np . dot ( np . nan_to_num ( A ) , np . nan_to_num ( B ) ) C [ should_be_nan ] = np . nan return C
returns np .