|
66 | 66 | The <declaration> gives a measure and its default parameters, and specifies
|
67 | 67 | its relation to its base measure. For example,
|
68 | 68 |
|
69 |
| - @measure Normal(μ,σ) ≃ Lebesgue{X} |
| 69 | + @measure Normal(μ,σ) |
70 | 70 |
|
71 |
| -declares the `Normal` is a measure with default parameters `μ and σ`, and it is |
72 |
| -equivalent to its base measure, which is `Lebesgue{X}` |
| 71 | +declares the `Normal` is a measure with default parameters `μ and σ`. The result is equivalent to |
| 72 | +``` |
| 73 | +struct Normal{N,T} <: ParameterizedMeasure{N} |
| 74 | + par :: NamedTuple{N,T} |
| 75 | +end |
73 | 76 |
|
74 |
| -You can see the generated code like this: |
| 77 | +KeywordCalls.@kwstruct Normal(μ,σ) |
75 | 78 |
|
76 |
| - julia> MacroTools.prettify(@macroexpand @measure Normal(μ,σ) ≃ Lebesgue{X}) |
77 |
| - quote |
78 |
| - struct Normal{P, X} <: AbstractMeasure |
79 |
| - par::P |
80 |
| - end |
81 |
| - function Normal(nt::NamedTuple) |
82 |
| - P = typeof(nt) |
83 |
| - return Normal{P, eltype(Normal{P})} |
84 |
| - end |
85 |
| - Normal(; kwargs...) = Normal((; kwargs...)) |
86 |
| - (basemeasure(μ::Normal{P, X}) where {P, X}) = Lebesgue{X} |
87 |
| - Normal(μ, σ) = Normal(; Any[:μ, :σ]) |
88 |
| - ((:≪)(::Normal{P, X}, ::Lebesgue{X}) where {P, X}) = true |
89 |
| - ((:≪)(::Lebesgue{X}, ::Normal{P, X}) where {P, X}) = true |
90 |
| - end |
| 79 | +Normal(μ,σ) = Normal((μ=μ, σ=σ)) |
| 80 | +``` |
91 | 81 |
|
92 |
| -Note that the `eltype` function needs to be defined separately by the user. |
| 82 | +See [KeywordCalls.jl](https://github.com/cscherrer/KeywordCalls.jl) for details on `@kwstruct`. |
93 | 83 | """
|
94 | 84 | macro measure(expr)
|
95 | 85 | esc(_measure(expr))
|
|
0 commit comments