Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve ambiguity in the prod method for ProductOf #15

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

bvdmitri
Copy link
Member

@bvdmitri bvdmitri commented Jul 3, 2024

This PR fixes a small issue with method ambiguity with certain parameters configuration for the prod function.

@bvdmitri bvdmitri requested a review from Nimrais July 3, 2024 11:55
Comment on lines +334 to +335
SomeArbitraryDistribution(),
ProductOf(SomeArbitraryDistribution(), SomeArbitraryDistribution()),
Copy link
Member

Choose a reason for hiding this comment

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

If I am not wrong PR tries to fix this as well?

julia> prod(GenericProd(), ProductOf(Normal(0, 1), Normal(0, 1)), ProductOf(Normal(0, 1), Normal(0, 1)))
ERROR: MethodError: prod(::GenericProd, ::ProductOf{Normal{Float64}, Normal{Float64}}, ::ProductOf{Normal{Float64}, Normal{Float64}}) is ambiguous.

Candidates:
  prod(::GenericProd, left::ProductOf{L, R}, right::T) where {L, R, T}
    @ BayesBase ~/.julia/packages/BayesBase/MnjV6/src/prod.jl:252
  prod(::GenericProd, left::T, right::ProductOf{L, R}) where {L, R, T}
    @ BayesBase ~/.julia/packages/BayesBase/MnjV6/src/prod.jl:285

Possible fix, define
  prod(::GenericProd, ::T, ::T) where {L, R, L, R, T<:ProductOf{L, R}, T<:ProductOf{L, R}}

Stacktrace:
 [1] top-level scope
   @ REPL[34]:1

Copy link
Member

Choose a reason for hiding this comment

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

Because it still fails on this branch for me.

Copy link
Member Author

Choose a reason for hiding this comment

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

this PR in particular is not aimed to solve this particular case, I think this one can be a separate issue, as it is can be quite complex in general

@bvdmitri bvdmitri merged commit c3fa178 into main Jul 4, 2024
2 checks passed
@wouterwln wouterwln deleted the ambiguity-in-prod branch October 9, 2024 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants