Skip to content

Commit

Permalink
Improve docs (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar committed Apr 15, 2024
1 parent d3ea51e commit ab98e76
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ julia> iter = Iterators.filter(x -> x != 10, 1:10^7);

julia> wv(el) = 1.0

julia> @btime itsample($rng, $iter, 10^4; replace=true);
julia> @btime itsample($rng, $iter, 10^4, algRSWRSKIP);
9.675 ms (4 allocations: 156.34 KiB)

julia> @btime itsample($rng, $iter, 10^4; replace=false);
julia> @btime itsample($rng, $iter, 10^4, algL);
7.889 ms (2 allocations: 78.17 KiB)

julia> @btime itsample($rng, $iter, $wv, 10^4; replace=true);
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
StreamSampling = "ef79a3d2-ae9f-5cd2-ab61-e13847810a6e"
StreamSampling = "ff63dad9-3335-55d8-95ec-f8139d39e468"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ makedocs(
pages = [
"API" => "index.md",
],
warnonly = [:doctest, :missing_docs, :cross_references],
)

@info "Deploying Documentation"
Expand Down
13 changes: 6 additions & 7 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ itsample
# Implemented ALgorithms

```@docs
StreamSampling.AlgL
StreamSampling.AlgR
StreamSampling.AlgRSWRSKIP
StreamSampling.AlgAExpJ
StreamSampling.AlgARes
StreamSampling.AlgWRSWRSKIP
StreamSampling.sortedindices_sample
StreamSampling.algL
StreamSampling.algR
StreamSampling.algRSWRSKIP
StreamSampling.algAExpJ
StreamSampling.algARes
StreamSampling.algWRSWRSKIP
```
24 changes: 12 additions & 12 deletions src/StreamSampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,45 @@ abstract type AbstractOrdWrReservoirSampleMulti <: AbstractWrReservoirSampleMult

abstract type ReservoirAlgorithm end

struct AlgL <: ReservoirAlgorithm end
struct AlgR <: ReservoirAlgorithm end
struct AlgRSWRSKIP <: ReservoirAlgorithm end
struct AlgARes <: ReservoirAlgorithm end
struct AlgAExpJ <: ReservoirAlgorithm end
struct AlgWRSWRSKIP <: ReservoirAlgorithm end

"""
Adapted from algorithm L described in "Random sampling with a reservoir, J. S. Vitter, 1985".
"""
struct AlgL <: ReservoirAlgorithm end
const algL = AlgL()

"""
Adapted from algorithm R described in "Random sampling with a reservoir, J. S. Vitter, 1985".
"""
struct AlgR <: ReservoirAlgorithm end
const algR = AlgR()

"""
Adapted fron algorithm RSWR_SKIP described in "Reservoir-based Random Sampling with Replacement from
Data Stream, B. Park et al., 2008".
"""
struct AlgRSWRSKIP <: ReservoirAlgorithm end
const algRSWRSKIP = AlgRSWRSKIP()

"""
Adapted from algorithm A-Res described in "Weighted random sampling with a reservoir,
P. S. Efraimidis et al., 2006".
"""
struct AlgARes <: ReservoirAlgorithm end
const algARes = AlgARes()

"""
Adapted from algorithm A-ExpJ described in "Weighted random sampling with a reservoir,
P. S. Efraimidis et al., 2006".
"""
struct AlgAExpJ <: ReservoirAlgorithm end
const algAExpJ = AlgAExpJ()

"""
Adapted from algorithm WRSWR_SKIP described in "A Skip-based Algorithm for Weighted Reservoir
Sampling with Replacement, A. Meligrana, 2024".
"""
struct AlgWRSWRSKIP <: ReservoirAlgorithm end

const algL = AlgL()
const algR = AlgR()
const algRSWRSKIP = AlgRSWRSKIP()
const algARes = AlgARes()
const algAExpJ = AlgAExpJ()
const algWRSWRSKIP = AlgWRSWRSKIP()

export algL, algR, algRSWRSKIP, algARes, algAExpJ, algWRSWRSKIP
Expand Down

0 comments on commit ab98e76

Please sign in to comment.