3232
3333# + results="hidden"
3434
35- using Observers
35+ using Observers: Observers, observer
3636
3737# Series for π/4
3838f (k) = (- 1 )^ (k + 1 ) / (2 k - 1 )
@@ -42,7 +42,7 @@ function my_iterative_function(niter; observer!, observe_step)
4242 for n in 1 : niter
4343 π_approx += f (n)
4444 if iszero (n % observe_step)
45- update! (observer!; iteration= n, π_approx= 4π _approx)
45+ Observers . update! (observer!; iteration= n, π_approx= 4π _approx)
4646 end
4747 end
4848 return 4π _approx
@@ -139,7 +139,7 @@ obs[!, Symbol(err)]
139139# ' You can also rename the columns to more desirable names using the `rename!`
140140# ' function from `DataFrames`:
141141# + term=true
142- using DataFrames
142+ using DataFrames: rename!
143143rename! (obs, [" Iteration" , " Error" ])
144144obs. Iteration
145145obs. Error
@@ -152,23 +152,23 @@ obs.Error
152152
153153# ' ## Accessing and modifying functions
154154
155- # ' You can access and modify functions of an observer with `get_function`, `set_function!`, and `insert_function!`:
155+ # ' You can access and modify functions of an observer with `Observers. get_function`, `Observers. set_function!`, and `Observers. insert_function!`:
156156# + term=true
157- get_function (obs, " Iteration" ) == iter
158- get_function (obs, " Error" ) == err
159- set_function! (obs, " Error" => sin);
160- get_function (obs, " Error" ) == sin
161- insert_function! (obs, " New column" => cos);
162- get_function (obs, " New column" ) == cos
157+ Observers . get_function (obs, " Iteration" ) == iter
158+ Observers . get_function (obs, " Error" ) == err
159+ Observers . set_function! (obs, " Error" => sin);
160+ Observers . get_function (obs, " Error" ) == sin
161+ Observers . insert_function! (obs, " New column" => cos);
162+ Observers . get_function (obs, " New column" ) == cos
163163obs
164164
165- # ' `set_function!` just updates the function of an existing column but doesn't create new columns,
166- # ' while `insert_function!` creates a new column and sets the function of that new column
165+ # ' `Observers. set_function!` just updates the function of an existing column but doesn't create new columns,
166+ # ' while `Observers. insert_function!` creates a new column and sets the function of that new column
167167# ' but won't update an existing column.
168168# ' For example, these will both throw errors:
169169# ' ```julia
170- # ' set_function!(obs, "New column 2", cos)
171- # ' insert_function!(obs, "Error", cos)
170+ # ' Observers. set_function!(obs, "New column 2", cos)
171+ # ' Observers. insert_function!(obs, "Error", cos)
172172# ' ```
173173
174174# ' Alternatively, if you define the observer with column names to begin with,
@@ -198,7 +198,8 @@ obs_loaded.Error == obs.Error
198198# ' [CSV file](https://dataframes.juliadata.org/stable/man/importing_and_exporting/#CSV-Files),
199199# ' though this will drop information about the functions associated with each column:
200200# + results="hidden"
201- using CSV
201+ using CSV: CSV
202+ using DataFrames: DataFrame
202203CSV. write (" results.csv" , obs)
203204obs_loaded = DataFrame (CSV. File (" results.csv" ))
204205# + term=true
@@ -211,8 +212,9 @@ obs_loaded.Error == obs.Error
211212# ' [Weave.jl](https://github.com/JunoLab/Weave.jl) with the following commands:
212213# + eval=false
213214
214- using Observers, Weave
215- weave (
215+ using Observers: Observers
216+ using Weave: Weave
217+ Weave. weave (
216218 joinpath (pkgdir (Observers), " examples" , " README.jl" );
217219 doctype= " github" ,
218220 out_path= pkgdir (Observers),
0 commit comments