Skip to content

Commit 05979bb

Browse files
committed
fix bug with gentype(Sampler(make(Sparse...)))
1 parent fcabd45 commit 05979bb

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/sampling.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,14 @@ make( p::AbstractFloat, d1::Integer, d2::Integer) = make(def
469469
make(::Type{String}, p::AbstractFloat, d1::Integer) = make(String, p, Dims(d1))
470470

471471
Sampler(RNG::Type{<:AbstractRNG}, c::Make3{A}, n::Repetition) where {A<:AbstractSparseArray} =
472-
SamplerTag{A}((sp = sampler(RNG, c.x, n),
473-
p = c.y,
474-
dims = c.z))
472+
SamplerTag{Cont{A}}((sp = sampler(RNG, c.x, n),
473+
p = c.y,
474+
dims = c.z))
475475

476-
rand(rng::AbstractRNG, sp::SamplerTag{A}) where {A<:SparseVector} =
476+
rand(rng::AbstractRNG, sp::SamplerTag{Cont{A}}) where {A<:SparseVector} =
477477
sprand(rng, sp.data.dims[1], sp.data.p, (r, n)->rand(r, sp.data.sp, n))
478478

479-
rand(rng::AbstractRNG, sp::SamplerTag{A}) where {A<:SparseMatrixCSC} =
479+
rand(rng::AbstractRNG, sp::SamplerTag{Cont{A}}) where {A<:SparseMatrixCSC} =
480480
sprand(rng, sp.data.dims[1], sp.data.dims[2], sp.data.p, (r, n)->rand(r, sp.data.sp, n), gentype(sp.data.sp))
481481

482482

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ end
478478
end
479479
@test rand(make(spString, 0.3, 9)) isa SparseVector{String}
480480
@test rand(make(String, 0.9, 2)) isa SparseVector{String} # can be ambiguous with make(String, chars, n)
481+
@test rand(make(make(1:9, 0.3, 2, 3), .1, 4)) isa SparseVector{SparseMatrixCSC{Int64,Int64},Int64}
481482
end
482483

483484
@testset "rand(make(default))" begin

0 commit comments

Comments
 (0)