Skip to content

Commit 051128e

Browse files
committed
Advances in documenation and tests.
1 parent 1e271b8 commit 051128e

File tree

7 files changed

+88
-24
lines changed

7 files changed

+88
-24
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ description = "StreamingSampling is a Julia-based proof-of-concept implementatio
88
Determinantal = "2673d5e8-682c-11e9-2dfd-471b09c6c819"
99
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
1010
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
11+
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
12+
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
1113
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1214
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1315
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

docs/make.jl

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,73 @@
11
using StreamingSampling
22
using Documenter
3+
using DocumenterCitations
4+
using Literate
35

4-
DocMeta.setdocmeta!(StreamingSampling, :DocTestSetup, :(using StreamingSampling); recursive=true)
5-
6-
makedocs(;
7-
modules=[StreamingSampling],
8-
authors="Emmanuel Lujan",
9-
sitename="StreamingSampling.jl",
10-
format=Documenter.HTML(;
11-
canonical="https://emmanuellujan.github.io/StreamingSampling.jl",
12-
edit_link="main",
13-
assets=String[],
14-
),
15-
pages=[
16-
"Home" => "index.md",
17-
],
6+
DocMeta.setdocmeta!(
7+
StreamingSampling,
8+
:DocTestSetup,
9+
:(using StreamingSampling);
10+
recursive = true,
11+
)
12+
13+
ENV["BASE_PATH"] = joinpath(@__DIR__, "../")
14+
15+
# Citations ####################################################################
16+
bib = CitationBibliography(joinpath(@__DIR__, "citation.bib"))
17+
18+
19+
# Generate examples ############################################################
20+
const examples_path = joinpath(@__DIR__, "..", "examples")
21+
const output_path = joinpath(@__DIR__, "src/generated")
22+
function create_examples(examples, examples_path, output_path)
23+
for (_, example_path) in examples
24+
s = split(example_path, "/")
25+
sub_path, file_name = string(s[1:end-1]...), s[end]
26+
example_filepath = joinpath(examples_path, example_path)
27+
Literate.markdown(example_filepath,
28+
joinpath(output_path, sub_path),
29+
documenter = true)
30+
end
31+
examples = [title => joinpath("generated", replace(example_path, ".jl" => ".md"))
32+
for (title, example_path) in examples]
33+
return examples
34+
end
35+
36+
# Basic examples
37+
examples = [
38+
"Simple example" => "simple-example/simple-example.jl",
39+
]
40+
basic_examples = create_examples(examples, examples_path, output_path)
41+
42+
# Make and deploy docs #########################################################
43+
44+
makedocs(
45+
root = joinpath(dirname(pathof(StreamingSampling)), "..", "docs"),
46+
source = "src",
47+
build = "build",
48+
clean = true,
49+
doctest = true,
50+
modules = [StreamingSampling],
51+
repo = "https://github.com/JuliaLabs/StreamingSampling.jl/blob/{commit}{path}#{line}",
52+
highlightsig = true,
53+
sitename = "StreamingSampling.jl",
54+
expandfirst = [],
55+
draft = false,
56+
pages = ["Home" => "index.md",
57+
"Install and run examples" => "install-and-run-examples.md",
58+
"Basic examples" => basic_examples,
59+
"API" => "api.md"],
60+
format = Documenter.HTML(;
61+
prettyurls = get(ENV, "CI", "false") == "true",
62+
canonical = "https://github.com/JuliaLabs/StreamingSampling.jl",
63+
assets = String[],
64+
),
65+
plugins=[bib]
1866
)
1967

2068
deploydocs(;
21-
repo="github.com/emmanuellujan/StreamingSampling.jl",
22-
devbranch="main",
69+
repo = "https://github.com/JuliaLabs/StreamingSampling.jl",
70+
devbranch = "main",
71+
push_preview = true,
2372
)
73+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
3+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
5+
StreamingSampling = "e1325ea1-13b9-452d-9115-4dbfefa12b3b"
File renamed without changes.

examples/sme-mvn/sme-mve.jl renamed to examples/simple-example/simple-example.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using StreamingSampling
2+
using LinearAlgebra
3+
using Distributions
24

35
include("gen-data.jl")
46

@@ -8,5 +10,5 @@ generate_data(file_paths)
810

911
# Sampling by StreamMaxEnt
1012
sme = StreamMaxEnt(file_paths; chunksize=200)
11-
inds = sample(sme, 100)
13+
inds = StreamingSampling.sample(sme, 100)
1214

examples/sme-mvn/Project.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/runtests.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@ using Statistics
1111
"data/data2.txt",
1212
"data/data3.txt",
1313
"data/data4.txt"]
14-
println("Checking sample size.")
1514
sme = StreamMaxEnt(file_paths; chunksize=1000, subchunksize=100)
16-
inds = StreamingSampling.sample(sme, 100)
17-
@test length(inds) == 100
15+
n = 100
16+
inds = StreamingSampling.sample(sme, n)
17+
ps = StreamingSampling.inclusion_prob(sme, n)
18+
19+
println("Checking sample size.")
20+
@test round(Int, sum(ps)) length(inds)
21+
22+
println("Checking sum(ps)==n.")
23+
@test round(Int, sum(ps)) n
24+
25+
println("Checking 0<=ps_i<=1.")
26+
@test all(0 .<= ps .<= 1)
1827
end
1928

2029
@testset "UPmaxentropy." begin

0 commit comments

Comments
 (0)