Skip to content

Better error message when attempting to return an ordered matrix sample #676

@CameronBieganek

Description

@CameronBieganek

This came up on Discourse.

a = [1, 2]
wv = weights([0.4, 0.6])
x = sample(a, wv, (2, 2), ordered=true)
julia> x = sample(a, wv, (3, 4), ordered=true)
ERROR: UndefKeywordError: keyword argument dims not assigned
Stacktrace:
 [1] sort!(::Array{Int64,2}) at ./sort.jl:1105
 [2] sample!(::Random._GLOBAL_RNG, ::Array{Int64,1}, ::Weights{Float64,Float64,Array{Float64,1}}, ::Array{Int64,2}; replace::Bool, ordered::Bool) at /Users/bieganek/.julia/packages/StatsBase/EA8Mh/src/sampling.jl:844
 [3] #sample#171 at /Users/bieganek/.julia/packages/StatsBase/EA8Mh/src/sampling.jl:878 [inlined]
 [4] #sample#172 at /Users/bieganek/.julia/packages/StatsBase/EA8Mh/src/sampling.jl:881 [inlined]
 [5] top-level scope at REPL[4]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions