Skip to content

Commit c2bcc8f

Browse files
committed
fix doctests
1 parent a7cb490 commit c2bcc8f

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

doc/src/devdocs/subarrays.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ julia> A = rand(2,3,4);
1919
2020
julia> S1 = view(A, :, 1, 2:3)
2121
2×2 view(::Array{Float64, 3}, :, 1, 2:3) with eltype Float64:
22-
0.200586 0.066423
23-
0.298614 0.956753
22+
0.762657 0.545403
23+
0.66338 0.866199
2424
2525
julia> S2 = view(A, 1, :, 2:3)
2626
3×2 view(::Array{Float64, 3}, 1, :, 2:3) with eltype Float64:
27-
0.200586 0.066423
28-
0.246837 0.646691
29-
0.648882 0.276021
27+
0.762657 0.545403
28+
0.704125 0.0802701
29+
0.886174 0.535537
3030
```
3131
```@meta
3232
DocTestSetup = nothing

doc/src/manual/performance-tips.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ julia> function sum_global()
7777
end;
7878
7979
julia> @time sum_global()
80-
0.009639 seconds (7.36 k allocations: 300.310 KiB, 98.32% compilation time)
81-
496.84883432553846
80+
0.011001 seconds (9.30 k allocations: 417.044 KiB, 98.77% compilation time)
81+
503.4466694614652
8282
8383
julia> @time sum_global()
84-
0.000140 seconds (3.49 k allocations: 70.313 KiB)
85-
496.84883432553846
84+
0.000075 seconds (3.49 k allocations: 70.156 KiB)
85+
503.4466694614652
8686
```
8787

8888
On the first call (`@time sum_global()`) the function gets compiled. (If you've not yet used [`@time`](@ref)
@@ -113,12 +113,12 @@ julia> function sum_arg(x)
113113
end;
114114
115115
julia> @time sum_arg(x)
116-
0.006202 seconds (4.18 k allocations: 217.860 KiB, 99.72% compilation time)
117-
496.84883432553846
116+
0.007258 seconds (4.24 k allocations: 226.052 KiB, 99.74% compilation time)
117+
503.4466694614652
118118
119119
julia> @time sum_arg(x)
120120
0.000005 seconds (1 allocation: 16 bytes)
121-
496.84883432553846
121+
503.4466694614652
122122
```
123123

124124
The 1 allocation seen is from running the `@time` macro itself in global scope. If we instead run
@@ -128,8 +128,8 @@ the timing in a function, we can see that indeed no allocations are performed:
128128
julia> time_sum(x) = @time sum_arg(x);
129129
130130
julia> time_sum(x)
131-
0.000001 seconds
132-
496.84883432553846
131+
0.000002 seconds
132+
503.4466694614652
133133
```
134134

135135
In some situations, your function may need to allocate memory as part of its operation, and this

stdlib/Random/docs/src/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,20 @@ Scalar and array methods for `Die` now work as expected:
147147

148148
```jldoctest Die; setup = :(Random.seed!(1))
149149
julia> rand(Die)
150-
Die(15)
150+
Die(6)
151151
152152
julia> rand(MersenneTwister(0), Die)
153153
Die(11)
154154
155155
julia> rand(Die, 3)
156156
3-element Vector{Die}:
157-
Die(18)
158-
Die(5)
157+
Die(15)
158+
Die(19)
159159
Die(4)
160160
161161
julia> a = Vector{Die}(undef, 3); rand!(a)
162162
3-element Vector{Die}:
163-
Die(5)
163+
Die(17)
164164
Die(20)
165165
Die(15)
166166
```
@@ -175,13 +175,13 @@ In order to define random generation out of objects of type `S`, the following m
175175
julia> Random.rand(rng::AbstractRNG, d::Random.SamplerTrivial{Die}) = rand(rng, 1:d[].nsides);
176176
177177
julia> rand(Die(4))
178-
3
178+
1
179179
180180
julia> rand(Die(4), 3)
181181
3-element Vector{Any}:
182+
3
182183
4
183184
1
184-
1
185185
```
186186

187187
Given a collection type `S`, it's currently assumed that if `rand(::S)` is defined, an object of type `eltype(S)` will be produced. In the last example, a `Vector{Any}` is produced; the reason is that `eltype(Die) == Any`. The remedy is to define `Base.eltype(::Type{Die}) = Int`.

stdlib/Random/src/misc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ number generator, see [Random Numbers](@ref).
5353
# Examples
5454
```jldoctest
5555
julia> Random.seed!(3); randstring()
56-
"Y7m62wOj"
56+
"vZmAMp3z"
5757
5858
julia> randstring(MersenneTwister(3), 'a':'z', 6)
5959
"ocucay"
6060
6161
julia> randstring("ACGT")
62-
"ATTTGCGT"
62+
"CAAACACC"
6363
```
6464
6565
!!! note

stdlib/SparseArrays/src/sparsematrix.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,13 +1585,13 @@ argument specifies a random number generator, see [Random Numbers](@ref).
15851585
# Examples
15861586
```jldoctest; setup = :(using Random; Random.seed!(1234))
15871587
julia> sprand(Bool, 2, 2, 0.5)
1588-
2×2 SparseMatrixCSC{Bool, Int64} with 1 stored entry:
1589-
⋅ ⋅
1590-
1
1588+
2×2 SparseMatrixCSC{Bool, Int64} with 4 stored entries:
1589+
1 1
1590+
1 1
15911591
15921592
julia> sprand(Float64, 3, 0.75)
15931593
3-element SparseVector{Float64, Int64} with 1 stored entry:
1594-
[3] = 0.298614
1594+
[1] = 0.66338
15951595
```
15961596
"""
15971597
function sprand(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloat, rfn::Function, ::Type{T}=eltype(rfn(r, 1))) where T
@@ -1632,9 +1632,9 @@ argument specifies a random number generator, see [Random Numbers](@ref).
16321632
# Examples
16331633
```jldoctest; setup = :(using Random; Random.seed!(0))
16341634
julia> sprandn(2, 2, 0.75)
1635-
2×2 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
1636-
⋅ 0.586617
1637-
⋅ 0.297336
1635+
2×2 SparseMatrixCSC{Float64, Int64} with 4 stored entries:
1636+
1.49137 1.09378
1637+
-1.56692 1.1035
16381638
```
16391639
"""
16401640
sprandn(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloat) =

0 commit comments

Comments
 (0)