Skip to content

Commit

Permalink
Fixed errors in docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Pieterjan Robbe committed May 28, 2020
1 parent 78f0d7c commit 778916f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 32 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
@@ -1,5 +1,5 @@
using LatticeRules
using Documenter
using LatticeRules

makedocs(;
modules=[LatticeRules],
Expand Down
3 changes: 0 additions & 3 deletions docs/src/index.md
Expand Up @@ -5,9 +5,6 @@ CurrentModule = LatticeRules
# LatticeRules

```@index
LatticeRule32
ShiftedLatticeRule32
getpoint
```

```@autodocs
Expand Down
33 changes: 15 additions & 18 deletions src/LatticeRule32.jl
Expand Up @@ -43,8 +43,7 @@ julia> getpoint(lattice_rule, 2)
```
See also: [`getpoint`](@ref), [`ShiftedLatticeRule32`](@ref)
"""
# specify generating vector
LatticeRule32(z::Vector{UInt32}) = LatticeRule32(z, length(z))
LatticeRule32(z::Vector{UInt32}) = LatticeRule32(z, length(z)) # specify generating vector

# specify generating vector and number of dimensions
LatticeRule32(z::Vector{UInt32}, s::Integer) = LatticeRule32(z, s, typemax(UInt32) + 1)
Expand Down Expand Up @@ -94,8 +93,7 @@ julia> getpoint(lattice_rule, 123)
```
See also: [`getpoint`](@ref), [`ShiftedLatticeRule32`](@ref)
"""
# specify file containing generating vector
LatticeRule32(file::AbstractString) = LatticeRule32(read32(file))
LatticeRule32(file::AbstractString) = LatticeRule32(read32(file)) # specify file containing generating vector

# specify file containting generating vector and number of dimensions
LatticeRule32(file::AbstractString, s::Integer) = LatticeRule32(read32(file), s)
Expand All @@ -116,27 +114,26 @@ LatticeRule32{16}
julia> getpoint(lattice_rule, 123)
16-element Array{Float64,1}:
0.8671875
0.9609375
0.5390625
0.6015625
0.8984375
0.6484375
0.3671875
0.6796875
0.8203125
0.3046875
0.8515625
0.7109375
0.6328125
0.3203125
0.2890625
0.0234375
0.1015625
0.7890625
0.0703125
0.5703125
0.2578125
0.6953125
0.0234375
0.1171875
0.0859375
0.0390625
0.2421875
0.4453125
```
See also: [`getpoint`](@ref), [`ShiftedLatticeRule32`](@ref)
"""
# specify number of dimensions only
function LatticeRule32(s::Integer)
function LatticeRule32(s::Integer) # specify number of dimensions only
s 3600 || throw(ArgumentError("number of dimensions s must be less than or equal to 3600, please supply your own generating vector z"))
s 250 ? LatticeRule32(CKN_250_20, s, 2^20) : LatticeRule32(K_3600_32, s)
end
Expand Down
10 changes: 4 additions & 6 deletions src/ShiftedLatticeRule32.jl
Expand Up @@ -49,10 +49,9 @@ julia> getpoint(shifted_lattice_rule, 0)
0.20947237319807077
```
See also: [`LatticeRule32`](@ref), [`get_point`](@ref)
See also: [`LatticeRule32`](@ref), [`getpoint`](@ref)
"""
# specify lattice rule
ShiftedLatticeRule32(lattice_rule::LatticeRule32{s}) where s = ShiftedLatticeRule32(lattice_rule, rand(s))
ShiftedLatticeRule32(lattice_rule::LatticeRule32{s}) where s = ShiftedLatticeRule32(lattice_rule, rand(s)) # specify lattice rule

# specify lattice rule and random shift
function ShiftedLatticeRule32(lattice_rule::LatticeRule32{s}, Δ::Vector{<:AbstractFloat}) where s
Expand All @@ -69,7 +68,7 @@ Returns a shifted rank-1 lattice rule in `s` dimensions that uses a default gene
# Examples
```jldoctest; setup = :(using LatticeRules; import Random; Random.seed!(1))
julia> shifted_lattice_rule = ShiftedLatticeRule32(16)
LatticeRule32{16}
ShiftedLatticeRule32{16}
julia> shifted_lattice_rule[0]
16-element Array{Float64,1}:
Expand All @@ -93,8 +92,7 @@ julia> shifted_lattice_rule[0]
```
See also: [`getpoint`](@ref), [`ShiftedLatticeRule32`](@ref)
"""
# specify number of dimensions only
ShiftedLatticeRule32(s::Integer) = ShiftedLatticeRule32(LatticeRule32(s))
ShiftedLatticeRule32(s::Integer) = ShiftedLatticeRule32(LatticeRule32(s)) # specify number of dimensions only

# in-place version of unsafe_getpoint (with 0 memory allocations)
@inline function unsafe_getpoint!(x::Vector{<:AbstractFloat}, shifted_lattice_rule::ShiftedLatticeRule32, k::UInt32)
Expand Down
5 changes: 2 additions & 3 deletions src/common.jl
Expand Up @@ -37,13 +37,12 @@ LatticeRule32{2}
julia> getpoint(lattice_rule, 3)
2-element Array{Float64,1}:
0.75
0.5
0.25
```
See also: [`LatticeRule32`](@ref), [`ShiftedLatticeRule32`](@ref)
"""
# get the k-th point of the lattice sequence
@inline function getpoint(lattice_rule::AbstractLatticeRule, k::Number)
@inline function getpoint(lattice_rule::AbstractLatticeRule, k::Number) # get the k-th point of the lattice sequence
0 k < length(lattice_rule) || throw(BoundsError(lattice_rule, k))
unsafe_getpoint(lattice_rule, convert(uinttype(lattice_rule), k))
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Expand Up @@ -78,7 +78,7 @@ using LatticeRules, SpecialFunctions, Statistics, Test
@test length(lattice_rule[0]) == 2
@inferred lattice_rule[100]
@test length(lattice_rule[end]) == 2
@test length(first(lattice_rule)) == 2
@test firstindex(lattice_rule) == 0
@test length(lattice_rule[1:20]) == 20
@test length(collect(lattice_rule)) == 2^20
end
Expand Down

0 comments on commit 778916f

Please sign in to comment.