Skip to content

Commit e26fd2e

Browse files
committed
Fix literate examples
1 parent c8bccbc commit e26fd2e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

docs/src/literate/example/algorithm.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ include("../../literate/example/example_include_all.jl") #hide
2121
# We first recall the algorithms we defined for OurRadonreco. We will use iterative methods to reconstruct the first three images from our time series. For more information, refer to the AbstractImageReconstruction documentation.
2222
# We first prepare our parameters. For this example we will use the Conjugate Gradient Normal Residual solver with 20 iterations and a L2 regularization of 0.001. Furthermore, we will project the final result to positive values:
2323
pre = RadonPreprocessingParameters(frames = collect(1:3))
24-
iter_reco = IterativeRadonReconstructionParameters(; shape = size(images)[1:3], angles = angles, iterations = 20, reg = [L2Regularization(0.001), PositiveRegularization()], solver = CGNR);
24+
iter_reco = IterativeRadonReconstructionParameters(; shape = size(images)[1:3], angles = angles, iterations = 20, reg = [L2Regularization(0.001)], solver = CGNR);
2525

2626
# We can construct the algorithm with our parameters:
2727
algo_iter = IterativeRadonAlgorithm(IterativeRadonParameters(pre, iter_reco));

docs/src/literate/example/daggerplan.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ dict = Dict{Symbol, Any}()
3131
dict[:shape] = size(images)[1:3]
3232
dict[:angles] = angles
3333
dict[:iterations] = 20
34-
dict[:reg] = [L2Regularization(0.001), PositiveRegularization()]
34+
dict[:reg] = [L2Regularization(0.001)]
3535
dict[:solver] = CGNR
3636
setAll!(plan_dagger, dict)
3737

3838
# To configure the algorithm with resources only available on the worker, such as files or GPU data, we can use the following interface:
3939
setproperty!(plan_dagger.parameter.algo.parameter.reco, :angles) do
4040
angles[1:2:end]
4141
end
42+
length(plan_dagger.parameter.algo.parameter.reco.angles) == length(1:2:length(angles))
4243
# The provided function is evaluated solely on the remote worker.
4344

4445
# Once the algorithm is fully configured, we can build and use it as usual:
46+
setAll!(plan_dagger, dict)
4547
imag_dagger = reconstruct(build(plan_dagger), sinograms)
4648
fig = Figure()
4749
for i = 1:3
@@ -70,19 +72,20 @@ toTOML(stdout, plan_dagger)
7072
# Additionally, listeners can be attached across workers using the Observable interface on a `DaggerRecoPlan`:
7173
using Observables
7274
localVariable = 3
73-
fun = on(plan_iter.parameter.pre, :frames) do newval
75+
plan_iter_remote = plan_dagger.parameter.algo
76+
fun = on(plan_iter_remote.parameter.pre, :frames) do newval
7477
@info "Number of frames was updated to: $(length(newval))"
7578
localVariable = length(newval)
7679
end
77-
setAll!(plan_iter, :frames, collect(1:42))
80+
setAll!(plan_iter_remote, :frames, collect(1:42))
7881

7982
# Note: We retain the observable function in the variable `fun` to allow for later removal of the listener. The anonymous function cannot be used directly due to internal listener management in **DaggerImageReconstruction**.
80-
off(plan_iter.parameter.pre, :frames, fun)
81-
setAll!(plan_iter, :frames, collect(1:32))
83+
off(plan_iter_remote.parameter.pre, :frames, fun)
84+
setAll!(plan_iter_remote, :frames, collect(1:32))
8285

8386
# Since the listener executes on the local worker, updated data must be transferred between workers. If this involves large data, a preprocessing function can be provided to the Observable:
84-
fun = on(plan_iter.parameter.pre, :frames; preprocessing = length) do newval
87+
fun = on(plan_iter_remote.parameter.pre, :frames; preprocessing = length) do newval
8588
@info "Number of frames was updated to: $(newval)"
8689
localVariable = newval
8790
end
88-
setAll!(plan_iter, :frames, collect(1:42))
91+
setAll!(plan_iter_remote, :frames, collect(1:42))

0 commit comments

Comments
 (0)