Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mhinsch committed Dec 5, 2024
1 parent 452744c commit 7597102
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 38 deletions.
7 changes: 4 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ makedocs(sitename="MiniObserve.jl",
collapselevel = 1
),
modules = [Observation, StatsAccumulatorBase, StatsAccumulator],
pages=["Home" => "index.md",
"Readme" => "README.md",
pages=[ "Introduction" => "README.md",
"Observation" => "obs.md",
"Stats Accumulators" => "stats.md"])
"StatsAccumulatorBase" => "statsbase.md",
"Stats Accumulators" => "stats.md",
"Index" => "index.md"])

deploydocs(
repo = "github.com/mhinsch/MiniObserve.jl.git",
Expand Down
36 changes: 1 addition & 35 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
# Introduction

Given a declaration

```Julia
@observe Data model user1 user2 begin
@record "time" model.time
@record "N" Int length(model.population)

@for ind in model.population begin
@stat("capital", MaxMinAcc{Float64}, MeanVarAcc{FloatT}) <| ind.capital
@stat("n_alone", CountAcc) <| has_neighbours(ind)
end

@record u1 user1
@record u2 user1 * user2
end
```

a type Data will be generated that provides (at least) the following members:

```Julia
struct Data
time :: Float64
N :: Int
capital :: @NamedTuple{max :: Float64, min :: Float64, mean :: Float64, var :: Float64}
n_alone :: @NamedTuple{N :: Int}
u1 :: Float64
u2 :: Float64
end
```

The macro will also create a method for `observe(::Type{Data), model...)` that will perform the required calculations and returns a `Data` object. Use `print_header` to print a header for the generated type to an output and `log_results` to print the content of a data object.

## Reference
# Index

```@index
```
7 changes: 7 additions & 0 deletions src/StatsAccumulatorBase.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
Accumulators can be used to calculate aggregate statistics over sets of elements. In order to be able to work with `@observe.@stat` an accumulator has to implement the following functions:
* `add!(acc, dat)` - add a datum to the accumulator. This function has no default implementation.
* `result_type(T)` - the type of the result the accumulator generates. Per default it is assumed that this is identical to the accumulator type itself.
* `result(acc)` - obtain the current result from the accumulator. Returns the accumulator object itself by default.
"""
module StatsAccumulatorBase

export results, result_type, add!
Expand Down

0 comments on commit 7597102

Please sign in to comment.