def combine_with_factor(self, other: LDFactor, func: Callable[([float, float], float)]):
    'Applies binary function to two factors.'
    for i in other.var_idx:
        assert (i in self.var_idx)
    for idx in range(len(self.p.p)):
        j = other._encode_value_index(self._decode_value_index(idx))
        self.p.p[idx] = func(self.p.p[idx], other.p.p[j])
    return self
Applies binary function to two factors.
def combine_with_factor(self, other: LDFactor, func: Callable[([float, float], float)]):
    
    for i in other.var_idx:
        assert (i in self.var_idx)
    for idx in range(len(self.p.p)):
        j = other._encode_value_index(self._decode_value_index(idx))
        self.p.p[idx] = func(self.p.p[idx], other.p.p[j])
    return self