Skip to content

Conversation

@Hen42rik
Copy link
Contributor

Adding a check for np.int64 type which is returned by WeightedCategorical priors.

Adding a check for np.int64 type as returned by Categorical priors.
@Hen42rik
Copy link
Contributor Author

Here is a MWE to reproduce the bug:

import numpy as np
from bilby.core.prior import ConditionalPriorDict, WeightedCategorical, Gaussian
from bilby.core.likelihood import  Likelihood
from bilby.core.sampler import  run_sampler

class DummyLikelihood(Likelihood):
    def log_likelihood(self, parameters):
        return -0.5 * np.sum([v for v in parameters.values()])**2
    
priordict = ConditionalPriorDict()
priordict["x"] = WeightedCategorical(name="x", ncategories=100)
priordict["y"] = Gaussian(name="y", mu=0, sigma=1)

run_sampler(likelihood=DummyLikelihood(priordict),
            priors=priordict,
            sampler="dynesty")

Copy link
Collaborator

@ColmTalbot ColmTalbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to get this in as a quick fix, but this behaviour should be fixed more generically in a future release.

@ColmTalbot ColmTalbot added bug Something isn't working <10 lines priors labels Jan 28, 2026
@mj-will mj-will added this to the 2.8.0 milestone Jan 28, 2026
@mj-will mj-will added this pull request to the merge queue Jan 28, 2026
Merged via the queue into bilby-dev:main with commit fe3b84c Jan 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priors <10 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants