You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/ref/trace_translators.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,10 +45,10 @@ end
45
45
The following trace transform DSL program defines a transformation (called `f`) that transforms traces of `p1` into traces of `p2`:
46
46
```julia
47
47
@transform f (t1) to (t2) begin
48
-
r =@read(t1[:r], continuous)
49
-
theta =@read(t1[theta], continuous)
50
-
@write(t2[:x], r *cos(theta), continuous)
51
-
@write(t2[:y], r *sin(theta), continuous)
48
+
r =@read(t1[:r], :continuous)
49
+
theta =@read(t1[theta], :continuous)
50
+
@write(t2[:x], r *cos(theta), :continuous)
51
+
@write(t2[:y], r *sin(theta), :continuous)
52
52
end
53
53
```
54
54
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`.
@@ -60,11 +60,11 @@ The inverse can provide a dynamic check that the transform truly is a bijection.
60
60
The inverse of the above transformation is:
61
61
```julia
62
62
@transform finv (t2) to (t1) begin
63
-
x =@read(t2[:x], continuous)
64
-
y =@read(t2[:y], continuous)
63
+
x =@read(t2[:x], :continuous)
64
+
y =@read(t2[:y], :continuous)
65
65
r =sqrt(x^2+ y^2)
66
-
@write(t1[:r], sqrt(x^2+ y^2), continuous)
67
-
@write(t1[:theta], atan(y, x), continuous)
66
+
@write(t1[:r], sqrt(x^2+ y^2), :continuous)
67
+
@write(t1[:theta], atan(y, x), :continuous)
68
68
end
69
69
```
70
70
We can inform Gen that two transforms are inverses of one another using [`pair_bijections!`](@ref):
0 commit comments