GammaShapeScale - changed the dispatch version of default_parametrization for Gamma #526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempt to solve #468 :
I changed the dispatch version of default_parametrization for Gamma to include a warning and then use the fallback version with lookup in ReactiveMP.
GraphPPL.default_parametrization(backend::ReactiveMPGraphPPLBackend, nodetype::GraphPPL.Atomic, factor::Type{Gamma}, rhs) = begin @warn "'Gamma' and 'GammaShapeScale' without keywords are constructed with parameters (Shape, Scale)." return GraphPPL.default_parametrization(backend, nodetype, ReactiveMP.inputinterfaces(factor), factor, rhs) end
This allows to define
GammaShapeScale(1,1)
as well asGamma(1,1)
both returning the warning as well asGamma{Float64}(α=1.0, θ=1.0)
Also added tests for initialization macro (but also works for model macro). not sure whether we should add further tests there as well.
TO-DO: if this sounds cool, we need to update test nr. 9 of "convert_init_node_aliases" in my other PR:
# Test 9: Positional Gamma should warn and be treated as (shape, scale) input = quote μ(x) = Gamma(2.0, 1.0) end @test_logs (:warn, "'Gamma' and 'GammaShapeScale' without keywords are constructed with parameters (Shape, Scale).") apply_pipeline(input, convert_init_node_aliases)