Skip to content

Commit fcabd45

Browse files
committed
disambiguate make(String, 0.3, 9)
1 parent 7c5adc7 commit fcabd45

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/sampling.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,16 @@ make(::Type{X}, p::AbstractFloat, dims::Dims{1}) where {X} = make(SparseVector,
457457
make(X, p::AbstractFloat, dims::Dims{2}) = make(SparseMatrixCSC, X, p, dims)
458458
make(::Type{X}, p::AbstractFloat, dims::Dims{2}) where {X} = make(SparseMatrixCSC, X, p, dims)
459459

460-
make(X, p::AbstractFloat, dims::Integer...) = make(X, p, Dims(dims))
461-
make(::Type{X}, p::AbstractFloat, dims::Integer...) where {X} = make(X, p, Dims(dims))
462-
make( p::AbstractFloat, dims::Dims) = make(default_sampling(AbstractArray), p, dims)
463-
make( p::AbstractFloat, dims::Integer...) = make(default_sampling(AbstractArray), p, Dims(dims))
464-
460+
make(X, p::AbstractFloat, d1::Integer) = make(X, p, Dims(d1))
461+
make(X, p::AbstractFloat, d1::Integer, d2::Integer) = make(X, p, Dims((d1, d2)))
462+
make(::Type{X}, p::AbstractFloat, d1::Integer) where {X} = make(X, p, Dims(d1))
463+
make(::Type{X}, p::AbstractFloat, d1::Integer, d2::Integer) where {X} = make(X, p, Dims((d1, d2)))
464+
make( p::AbstractFloat, dims::Dims) = make(default_sampling(AbstractArray), p, dims)
465+
make( p::AbstractFloat, d1::Integer) = make(default_sampling(AbstractArray), p, Dims(d1))
466+
make( p::AbstractFloat, d1::Integer, d2::Integer) = make(default_sampling(AbstractArray), p, Dims((d1, d2)))
467+
468+
# disambiguate (away from make(String, chars, n::Integer))
469+
make(::Type{String}, p::AbstractFloat, d1::Integer) = make(String, p, Dims(d1))
465470

466471
Sampler(RNG::Type{<:AbstractRNG}, c::Make3{A}, n::Repetition) where {A<:AbstractSparseArray} =
467472
SamplerTag{A}((sp = sampler(RNG, c.x, n),

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ end
477477
@test length(s) == 6
478478
end
479479
@test rand(make(spString, 0.3, 9)) isa SparseVector{String}
480+
@test rand(make(String, 0.9, 2)) isa SparseVector{String} # can be ambiguous with make(String, chars, n)
480481
end
481482

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

0 commit comments

Comments
 (0)