Skip to content

Problem merging results due to inconsistent priors

I've just been trying to use bilby_result to merge two parallel runs on the same data with the same priors. However, it fails with the error bilby.core.result.ResultListError: Inconsistent priors between results.

I think this is due to how __eq__ is implemented in the Prior class. It checks all the attributes of the prior class for equality including the least_recently_sampled. However, for priors from different runs these should just be independent random samples from the prior, so should not be the same. So, unless I'm missing something, I think the __eq__ method in the Prior class should instead be:

    def __eq__(self, other):
        if self.__class__ != other.__class__:
            return False
        if sorted(self.__dict__.keys()) != sorted(other.__dict__.keys()):
            return False
        for key in self.__dict__:
            if key == "least_recently_sampled":
                # do not compare recent prior sample
                continue
            if type(self.__dict__[key]) is np.ndarray:
                if not np.array_equal(self.__dict__[key], other.__dict__[key]):
                    return False
            elif isinstance(self.__dict__[key], type(scipy.stats.beta(1., 1.))):
                continue
            else:
                if not self.__dict__[key] == other.__dict__[key]:
                    return False
        return True