Skip to content

Commit

Permalink
Merge pull request #383 from SamWitty/patch-2
Browse files Browse the repository at this point in the history
Typo fix in TraceTranslator doc example
  • Loading branch information
marcoct authored Feb 18, 2021
2 parents 7a458b8 + fe560da commit e5ed96f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/src/ref/trace_translators.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ end
The following trace transform DSL program defines a transformation (called `f`) that transforms traces of `p1` into traces of `p2`:
```julia
@transform f (t1) to (t2) begin
r = @read(t1[:r], continuous)
theta = @read(t1[theta], continuous)
@write(t2[:x], r * cos(theta), continuous)
@write(t2[:y], r * sin(theta), continuous)
r = @read(t1[:r], :continuous)
theta = @read(t1[theta], :continuous)
@write(t2[:x], r * cos(theta), :continuous)
@write(t2[:y], r * sin(theta), :continuous)
end
```
This transform reads values of random choices in the input trace (`t1`) at specific addresses (indicated by the syntax `t1[addr]`) using `@read` and writes values to the output trace (`t2`) using `@write`.
Expand All @@ -60,11 +60,11 @@ The inverse can provide a dynamic check that the transform truly is a bijection.
The inverse of the above transformation is:
```julia
@transform finv (t2) to (t1) begin
x = @read(t2[:x], continuous)
y = @read(t2[:y], continuous)
x = @read(t2[:x], :continuous)
y = @read(t2[:y], :continuous)
r = sqrt(x^2 + y^2)
@write(t1[:r], sqrt(x^2 + y^2), continuous)
@write(t1[:theta], atan(y, x), continuous)
@write(t1[:r], sqrt(x^2 + y^2), :continuous)
@write(t1[:theta], atan(y, x), :continuous)
end
```
We can inform Gen that two transforms are inverses of one another using [`pair_bijections!`](@ref):
Expand Down

0 comments on commit e5ed96f

Please sign in to comment.