Skip to content

Commit 04d24fb

Browse files
abhrodlfivefifty
andauthored
Add documentation GH Action and update README.md examples (#382)
* Add compat bounds for Documenter.jl in docs/Project.toml * Add GitHub Actions workflow for building docs * Update code block examples in README.md - Use outputs from newer Julia versions and LazyArrays versions - Add missing import for reproducibility * Update ci.yml Signed-off-by: Sheehan Olver <[email protected]> --------- Signed-off-by: Sheehan Olver <[email protected]> Co-authored-by: Sheehan Olver <[email protected]>
1 parent 33a2bbd commit 04d24fb

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
version:
1515
- 'lts'
1616
- '1'
17-
- 'pre'
1817
os:
1918
- ubuntu-latest
2019
- macOS-latest

.github/workflows/docs.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Documentation
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags: '*'
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
# These permissions are needed to:
12+
# - Deploy the documentation: https://documenter.juliadocs.org/stable/man/hosting/#Permissions
13+
# - Delete old caches: https://github.com/julia-actions/cache#usage
14+
permissions:
15+
actions: write
16+
contents: write
17+
pull-requests: read
18+
statuses: write
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v5
22+
- uses: julia-actions/setup-julia@v2
23+
with:
24+
version: '1'
25+
- uses: julia-actions/cache@v2
26+
- name: Install dependencies
27+
shell: julia --color=yes --project=docs {0}
28+
run: |
29+
using Pkg
30+
Pkg.develop(PackageSpec(path=pwd()))
31+
Pkg.instantiate()
32+
- name: Build and deploy
33+
run: julia --color=yes --project=docs docs/make.jl
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
36+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,31 @@ implemented in `BLAS.gemv!` using a lazy applied object:
5858
julia> A = randn(5,5); b = randn(5); c = randn(5); d = similar(c);
5959

6060
julia> d .= @~ 2.0 * A * b + 3.0 * c # Calls gemv!
61-
5-element Array{Float64,1}:
61+
5-element Vector{Float64}:
6262
-2.5366335879717514
6363
-5.305097174484744
6464
-9.818431932350942
6565
2.421562605495651
6666
0.26792916096572983
6767

6868
julia> 2*(A*b) + 3c
69-
5-element Array{Float64,1}:
69+
5-element Vector{Float64}:
7070
-2.5366335879717514
7171
-5.305097174484744
7272
-9.818431932350942
7373
2.421562605495651
7474
0.26792916096572983
7575

7676
julia> function mymul(A, b, c, d) # need to put in function for benchmarking
77-
d .= @~ 2.0 * A * b + 3.0 * c
77+
d .= @~ 2.0 * A * b + 3.0 * c
7878
end
7979
mymul (generic function with 1 method)
8080

81+
julia> using BenchmarkTools
82+
8183
julia> @btime mymul(A, b, c, d) # calls gemv!
8284
77.444 ns (0 allocations: 0 bytes)
83-
5-element Array{Float64,1}:
85+
5-element Vector{Float64}:
8486
-2.5366335879717514
8587
-5.305097174484744
8688
-9.818431932350942
@@ -96,7 +98,7 @@ This also works for inverses, which lower to BLAS calls whenever possible:
9698
julia> A = randn(5,5); b = randn(5); c = similar(b);
9799

98100
julia> c .= @~ A \ b
99-
5-element Array{Float64,1}:
101+
5-element Vector{Float64}:
100102
-2.5366335879717514
101103
-5.305097174484744
102104
-9.818431932350942
@@ -105,22 +107,21 @@ julia> c .= @~ A \ b
105107
```
106108

107109

108-
109110
## Lazy arrays
110111

111112
Often we want lazy realizations of matrices, which are supported via `ApplyArray`.
112113
For example, the following creates a lazy matrix exponential:
113114
```julia
114115
julia> E = ApplyArray(exp, [1 2; 3 4])
115-
2×2 ApplyArray{Float64,2,typeof(exp),Tuple{Array{Int64,2}}}:
116+
exp(2×2 Matrix{Int64}):
116117
51.969 74.7366
117118
112.105 164.074
118119
```
119120

120121
A lazy matrix exponential is useful for, say, in-place matrix-exponential*vector:
121122
```julia
122123
julia> b = Vector{Float64}(undef, 2); b .= @~ E*[4,4]
123-
2-element Array{Float64,1}:
124+
2-element Vector{Float64}:
124125
506.8220830628333
125126
1104.7145995988594
126127
```
@@ -138,7 +139,7 @@ vectors without actually allocating memory, and support a fast
138139
julia> using BenchmarkTools
139140

140141
julia> A = ApplyArray(vcat,1:5,2:3) # allocation-free
141-
7-element ApplyArray{Int64,1,typeof(vcat),Tuple{UnitRange{Int64},UnitRange{Int64}}}:
142+
vcat(5-element UnitRange{Int64}, 2-element UnitRange{Int64}):
142143
1
143144
2
144145
3
@@ -159,7 +160,7 @@ julia> @btime vcat(1:5, 2:3); # takes twice as long due to memory creation
159160
Similar is the lazy analogue of `hcat`:
160161
```julia
161162
julia> A = ApplyArray(hcat, 1:3, randn(3,10))
162-
3×11 ApplyArray{Float64,2,typeof(hcat),Tuple{UnitRange{Int64},Array{Float64,2}}}:
163+
hcat(3-element UnitRange{Int64}, 3×10 Matrix{Float64}):
163164
1.0 1.16561 0.224871 -1.36416 -0.30675 0.103714 0.590141 0.982382 -1.50045 0.323747 -1.28173
164165
2.0 1.04648 1.35506 -0.147157 0.995657 -0.616321 -0.128672 -0.671445 -0.563587 -0.268389 -1.71004
165166
3.0 -0.433093 -0.325207 -1.38496 -0.391113 -0.0568739 -1.55796 -1.00747 0.473686 -1.2113 0.0119156
@@ -185,7 +186,7 @@ array:
185186
julia> A = randn(2,2); B = randn(3,3);
186187

187188
julia> K = ApplyArray(kron,A,B)
188-
6×6 ApplyArray{Float64,2,typeof(kron),Tuple{Array{Float64,2},Array{Float64,2}}}:
189+
kron(2×2 Matrix{Float64}, 3×3 Matrix{Float64}):
189190
-1.08736 -0.19547 -0.132824 1.60531 0.288579 0.196093
190191
0.353898 0.445557 -0.257776 -0.522472 -0.657791 0.380564
191192
-0.723707 0.911737 -0.710378 1.06843 -1.34603 1.04876

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
4+
[compat]
5+
Documenter = "1"

0 commit comments

Comments
 (0)