prompt
stringlengths
5.33k
21.1k
metadata
dict
context_start_lineno
int64
1
913
line_no
int64
16
984
repo
stringclasses
5 values
id
int64
0
416
target_function_prompt
stringlengths
201
13.6k
function_signature
stringlengths
7
453
solution_position
listlengths
2
2
raw_solution
stringlengths
201
13.6k
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "optimisation", "Optimisation.jl" ], "ground_truth": "function StatsBase.coeftable(m::ModeResult; level::Real=0.95, numerrors_warnonly::Bool=true)\n # Get columns for coeftable.\n terms = string.(StatsBase.coefnames(m))\n estimates = m.values.array[:...
250
319
Turing.jl
400
function StatsBase.coeftable(m::ModeResult; level::Real=0.95, numerrors_warnonly::Bool=true) # Get columns for coeftable. terms = string.(StatsBase.coefnames(m)) estimates = m.values.array[:, 1] # If numerrors_warnonly is true, and if either the information matrix is singular or has # negative entri...
StatsBase.coeftable(m::ModeResult; level::Real=0.95, numerrors_warnonly::Bool=true)
[ 250, 319 ]
function StatsBase.coeftable(m::ModeResult; level::Real=0.95, numerrors_warnonly::Bool=true) # Get columns for coeftable. terms = string.(StatsBase.coefnames(m)) estimates = m.values.array[:, 1] # If numerrors_warnonly is true, and if either the information matrix is singular or has # negative entri...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "optimisation", "Optimisation.jl" ], "ground_truth": "function StatsBase.informationmatrix(\n m::ModeResult; hessian_function=ForwardDiff.hessian, kwargs...\n)\n # Calculate Hessian and information matrix.\n\n # Convert the values to their unconstrai...
321
348
Turing.jl
401
function StatsBase.informationmatrix( m::ModeResult; hessian_function=ForwardDiff.hessian, kwargs... ) # Calculate Hessian and information matrix. # Convert the values to their unconstrained states to make sure the # Hessian is computed with respect to the untransformed parameters. linked = Dynamic...
StatsBase.informationmatrix( m::ModeResult; hessian_function=ForwardDiff.hessian, kwargs... )
[ 321, 348 ]
function StatsBase.informationmatrix( m::ModeResult; hessian_function=ForwardDiff.hessian, kwargs... ) # Calculate Hessian and information matrix. # Convert the values to their unconstrained states to make sure the # Hessian is computed with respect to the untransformed parameters. linked = Dynamic...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "optimisation", "Optimisation.jl" ], "ground_truth": "function Base.get(m::ModeResult, var_symbols::AbstractVector{Symbol})\n log_density = m.f.ldf\n # Get all the variable names in the model. This is the same as the list of keys in\n # m.values, but...
364
383
Turing.jl
402
function Base.get(m::ModeResult, var_symbols::AbstractVector{Symbol}) log_density = m.f.ldf # Get all the variable names in the model. This is the same as the list of keys in # m.values, but they are more convenient to filter when they are VarNames rather than # Symbols. varnames = collect( ...
Base.get(m::ModeResult, var_symbols::AbstractVector{Symbol})
[ 364, 383 ]
function Base.get(m::ModeResult, var_symbols::AbstractVector{Symbol}) log_density = m.f.ldf # Get all the variable names in the model. This is the same as the list of keys in # m.values, but they are more convenient to filter when they are VarNames rather than # Symbols. varnames = collect( ...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "optimisation", "Optimisation.jl" ], "ground_truth": "function generate_initial_params(model::DynamicPPL.Model, initial_params, constraints)\n if initial_params === nothing && has_generic_constraints(constraints)\n throw(\n ArgumentError(...
450
469
Turing.jl
403
function generate_initial_params(model::DynamicPPL.Model, initial_params, constraints) if initial_params === nothing && has_generic_constraints(constraints) throw( ArgumentError( "You must provide an initial value when using generic constraints." ), ) end ...
generate_initial_params(model::DynamicPPL.Model, initial_params, constraints)
[ 450, 469 ]
function generate_initial_params(model::DynamicPPL.Model, initial_params, constraints) if initial_params === nothing && has_generic_constraints(constraints) throw( ArgumentError( "You must provide an initial value when using generic constraints." ), ) end ...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "optimisation", "Optimisation.jl" ], "ground_truth": "function Optimization.OptimizationProblem(log_density::OptimLogDensity, adtype, constraints)\n # Note that OptimLogDensity is a callable that evaluates the model with given\n # parameters. Hence we c...
487
505
Turing.jl
404
function Optimization.OptimizationProblem(log_density::OptimLogDensity, adtype, constraints) # Note that OptimLogDensity is a callable that evaluates the model with given # parameters. Hence we can use it in the objective function as below. f = Optimization.OptimizationFunction(log_density, adtype; cons=con...
Optimization.OptimizationProblem(log_density::OptimLogDensity, adtype, constraints)
[ 487, 505 ]
function Optimization.OptimizationProblem(log_density::OptimLogDensity, adtype, constraints) # Note that OptimLogDensity is a callable that evaluates the model with given # parameters. Hence we can use it in the objective function as below. f = Optimization.OptimizationFunction(log_density, adtype; cons=con...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "optimisation", "Optimisation.jl" ], "ground_truth": "function estimate_mode(\n model::DynamicPPL.Model,\n estimator::ModeEstimator,\n solver=nothing;\n check_model::Bool=true,\n initial_params=nothing,\n adtype=ADTypes.AutoForwardDiff(),\n ...
539
595
Turing.jl
405
function estimate_mode( model::DynamicPPL.Model, estimator::ModeEstimator, solver=nothing; check_model::Bool=true, initial_params=nothing, adtype=ADTypes.AutoForwardDiff(), cons=nothing, lcons=nothing, ucons=nothing, lb=nothing, ub=nothing, kwargs..., ) check_model &&...
estimate_mode( model::DynamicPPL.Model, estimator::ModeEstimator, solver=nothing; check_model::Bool=true, initial_params=nothing, adtype=ADTypes.AutoForwardDiff(), cons=nothing, lcons=nothing, ucons=nothing, lb=nothing, ub=nothing, kwargs..., )
[ 539, 595 ]
function estimate_mode( model::DynamicPPL.Model, estimator::ModeEstimator, solver=nothing; check_model::Bool=true, initial_params=nothing, adtype=ADTypes.AutoForwardDiff(), cons=nothing, lcons=nothing, ucons=nothing, lb=nothing, ub=nothing, kwargs..., ) check_model &&...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "stdlib", "distributions.jl" ], "ground_truth": "function unsafe_logpdf_ordered_logistic(η, cutpoints, K, k::Int)\n @inbounds begin\n logp = if k == 1\n -StatsFuns.log1pexp(η - cutpoints[k])\n elseif k < K\n tmp = StatsF...
164
176
Turing.jl
406
function unsafe_logpdf_ordered_logistic(η, cutpoints, K, k::Int) @inbounds begin logp = if k == 1 -StatsFuns.log1pexp(η - cutpoints[k]) elseif k < K tmp = StatsFuns.log1pexp(cutpoints[k - 1] - η) -tmp + StatsFuns.log1mexp(tmp - StatsFuns.log1pexp(cutpoints[k] - η)...
unsafe_logpdf_ordered_logistic(η, cutpoints, K, k::Int)
[ 164, 176 ]
function unsafe_logpdf_ordered_logistic(η, cutpoints, K, k::Int) @inbounds begin logp = if k == 1 -StatsFuns.log1pexp(η - cutpoints[k]) elseif k < K tmp = StatsFuns.log1pexp(cutpoints[k - 1] - η) -tmp + StatsFuns.log1mexp(tmp - StatsFuns.log1pexp(cutpoints[k] - η)...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "stdlib", "RandomMeasures.jl" ], "ground_truth": "function _logpdf_table(d::DirichletProcess{T}, m::AbstractVector{Int}) where {T<:Real}\n\n # construct the table\n first_zero = findfirst(iszero, m)\n K = first_zero === nothing ? length(m) + 1 : leng...
133
156
Turing.jl
407
function _logpdf_table(d::DirichletProcess{T}, m::AbstractVector{Int}) where {T<:Real} # construct the table first_zero = findfirst(iszero, m) K = first_zero === nothing ? length(m) + 1 : length(m) table = fill(T(-Inf), K) # exit if m is empty or contains only zeros if iszero(m) table[...
_logpdf_table(d::DirichletProcess{T}, m::AbstractVector{Int}) where {T<:Real}
[ 133, 156 ]
function _logpdf_table(d::DirichletProcess{T}, m::AbstractVector{Int}) where {T<:Real} # construct the table first_zero = findfirst(iszero, m) K = first_zero === nothing ? length(m) + 1 : length(m) table = fill(T(-Inf), K) # exit if m is empty or contains only zeros if iszero(m) table[...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "stdlib", "RandomMeasures.jl" ], "ground_truth": "function stickbreak(v)\n K = length(v) + 1\n cumprod_one_minus_v = cumprod(1 .- v)\n\n eta = [\n if k == 1\n v[1]\n elseif k == K\n cumprod_one_minus_v[K - 1]\n ...
218
233
Turing.jl
408
function stickbreak(v) K = length(v) + 1 cumprod_one_minus_v = cumprod(1 .- v) eta = [ if k == 1 v[1] elseif k == K cumprod_one_minus_v[K - 1] else v[k] * cumprod_one_minus_v[k - 1] end for k in 1:K ] return eta end
stickbreak(v)
[ 218, 233 ]
function stickbreak(v) K = length(v) + 1 cumprod_one_minus_v = cumprod(1 .- v) eta = [ if k == 1 v[1] elseif k == K cumprod_one_minus_v[K - 1] else v[k] * cumprod_one_minus_v[k - 1] end for k in 1:K ] return eta end
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "stdlib", "RandomMeasures.jl" ], "ground_truth": "function _logpdf_table(d::PitmanYorProcess{T}, m::AbstractVector{Int}) where {T<:Real}\n # sanity check\n @assert d.t == sum(!iszero, m)\n\n # construct table\n first_zero = findfirst(iszero, m)\n ...
242
267
Turing.jl
409
function _logpdf_table(d::PitmanYorProcess{T}, m::AbstractVector{Int}) where {T<:Real} # sanity check @assert d.t == sum(!iszero, m) # construct table first_zero = findfirst(iszero, m) K = first_zero === nothing ? length(m) + 1 : length(m) table = fill(T(-Inf), K) # exit if m is empty or c...
_logpdf_table(d::PitmanYorProcess{T}, m::AbstractVector{Int}) where {T<:Real}
[ 242, 267 ]
function _logpdf_table(d::PitmanYorProcess{T}, m::AbstractVector{Int}) where {T<:Real} # sanity check @assert d.t == sum(!iszero, m) # construct table first_zero = findfirst(iszero, m) K = first_zero === nothing ? length(m) + 1 : length(m) table = fill(T(-Inf), K) # exit if m is empty or c...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "variational", "deprecated.jl" ], "ground_truth": "function ADVI(\n samples_per_step::Int=1,\n max_iters::Int=1000;\n adtype::ADTypes.AbstractADType=ADTypes.AutoForwardDiff(),\n)\n Base.depwarn(\n \"The type ADVI will be removed in future r...
16
27
Turing.jl
410
function ADVI( samples_per_step::Int=1, max_iters::Int=1000; adtype::ADTypes.AbstractADType=ADTypes.AutoForwardDiff(), ) Base.depwarn( "The type ADVI will be removed in future releases. Please refer to the new interface for `vi`", :ADVI; force=true, ) return ADVI{typeof(a...
ADVI( samples_per_step::Int=1, max_iters::Int=1000; adtype::ADTypes.AbstractADType=ADTypes.AutoForwardDiff(), )
[ 16, 27 ]
function ADVI( samples_per_step::Int=1, max_iters::Int=1000; adtype::ADTypes.AbstractADType=ADTypes.AutoForwardDiff(), ) Base.depwarn( "The type ADVI will be removed in future releases. Please refer to the new interface for `vi`", :ADVI; force=true, ) return ADVI{typeof(a...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "variational", "deprecated.jl" ], "ground_truth": "function vi(model::DynamicPPL.Model, alg::ADVI; kwargs...)\n Base.depwarn(\n \"This specialization along with the type `ADVI` will be deprecated in future releases. Please refer to the new interfac...
29
42
Turing.jl
411
function vi(model::DynamicPPL.Model, alg::ADVI; kwargs...) Base.depwarn( "This specialization along with the type `ADVI` will be deprecated in future releases. Please refer to the new interface for `vi`.", :vi; force=true, ) q = q_meanfield_gaussian(Random.default_rng(), model) ...
vi(model::DynamicPPL.Model, alg::ADVI; kwargs...)
[ 29, 42 ]
function vi(model::DynamicPPL.Model, alg::ADVI; kwargs...) Base.depwarn( "This specialization along with the type `ADVI` will be deprecated in future releases. Please refer to the new interface for `vi`.", :vi; force=true, ) q = q_meanfield_gaussian(Random.default_rng(), model) ...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "variational", "deprecated.jl" ], "ground_truth": "function vi(\n model::DynamicPPL.Model,\n alg::ADVI,\n q::Bijectors.TransformedDistribution{<:DistributionsAD.TuringDiagMvNormal};\n kwargs...,\n)\n Base.depwarn(\n \"This specialization...
44
61
Turing.jl
412
function vi( model::DynamicPPL.Model, alg::ADVI, q::Bijectors.TransformedDistribution{<:DistributionsAD.TuringDiagMvNormal}; kwargs..., ) Base.depwarn( "This specialization along with the type `ADVI` will be deprecated in future releases. Please refer to the new interface for `vi`.", ...
vi( model::DynamicPPL.Model, alg::ADVI, q::Bijectors.TransformedDistribution{<:DistributionsAD.TuringDiagMvNormal}; kwargs..., )
[ 44, 61 ]
function vi( model::DynamicPPL.Model, alg::ADVI, q::Bijectors.TransformedDistribution{<:DistributionsAD.TuringDiagMvNormal}; kwargs..., ) Base.depwarn( "This specialization along with the type `ADVI` will be deprecated in future releases. Please refer to the new interface for `vi`.", ...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "variational", "VariationalInference.jl" ], "ground_truth": "function q_locationscale(\n rng::Random.AbstractRNG,\n model::DynamicPPL.Model;\n location::Union{Nothing,<:AbstractVector}=nothing,\n scale::Union{Nothing,<:Diagonal,<:LowerTriangular}=...
130
170
Turing.jl
413
function q_locationscale( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:Diagonal,<:LowerTriangular}=nothing, meanfield::Bool=true, basedist::Distributions.UnivariateDistribution=Normal(), kwargs..., ) varinfo =...
q_locationscale( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:Diagonal,<:LowerTriangular}=nothing, meanfield::Bool=true, basedist::Distributions.UnivariateDistribution=Normal(), kwargs..., )
[ 130, 170 ]
function q_locationscale( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:Diagonal,<:LowerTriangular}=nothing, meanfield::Bool=true, basedist::Distributions.UnivariateDistribution=Normal(), kwargs..., ) varinfo =...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "variational", "VariationalInference.jl" ], "ground_truth": "function q_meanfield_gaussian(\n rng::Random.AbstractRNG,\n model::DynamicPPL.Model;\n location::Union{Nothing,<:AbstractVector}=nothing,\n scale::Union{Nothing,<:Diagonal}=nothing,\n ...
199
209
Turing.jl
414
function q_meanfield_gaussian( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:Diagonal}=nothing, kwargs..., ) return q_locationscale( rng, model; location, scale, meanfield=true, basedist=Normal(), kwargs... ...
q_meanfield_gaussian( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:Diagonal}=nothing, kwargs..., )
[ 199, 209 ]
function q_meanfield_gaussian( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:Diagonal}=nothing, kwargs..., ) return q_locationscale( rng, model; location, scale, meanfield=true, basedist=Normal(), kwargs... ...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "variational", "VariationalInference.jl" ], "ground_truth": "function q_fullrank_gaussian(\n rng::Random.AbstractRNG,\n model::DynamicPPL.Model;\n location::Union{Nothing,<:AbstractVector}=nothing,\n scale::Union{Nothing,<:LowerTriangular}=nothing...
238
248
Turing.jl
415
function q_fullrank_gaussian( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:LowerTriangular}=nothing, kwargs..., ) return q_locationscale( rng, model; location, scale, meanfield=false, basedist=Normal(), kwargs...
q_fullrank_gaussian( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:LowerTriangular}=nothing, kwargs..., )
[ 238, 248 ]
function q_fullrank_gaussian( rng::Random.AbstractRNG, model::DynamicPPL.Model; location::Union{Nothing,<:AbstractVector}=nothing, scale::Union{Nothing,<:LowerTriangular}=nothing, kwargs..., ) return q_locationscale( rng, model; location, scale, meanfield=false, basedist=Normal(), kwargs...
Your task is to generate only the test code for the given focal function in Julia programming language. Instructions: - Use the Test module with idiomatic @testset and @test macros. - (IMPORTANT) Always refer to the focal function using the module_name.function_name format — even if it is exported. - Do NOT rewrite or...
{ "fpath_tuple": [ "Turing.jl", "src", "variational", "VariationalInference.jl" ], "ground_truth": "function vi(\n rng::Random.AbstractRNG,\n model::DynamicPPL.Model,\n q,\n n_iterations::Int;\n objective=AdvancedVI.RepGradELBO(\n 10; entropy=AdvancedVI.ClosedFormEntropyZeroG...
295
323
Turing.jl
416
function vi( rng::Random.AbstractRNG, model::DynamicPPL.Model, q, n_iterations::Int; objective=AdvancedVI.RepGradELBO( 10; entropy=AdvancedVI.ClosedFormEntropyZeroGradient() ), show_progress::Bool=PROGRESS[], optimizer=AdvancedVI.DoWG(), averager=AdvancedVI.PolynomialAveragin...
vi( rng::Random.AbstractRNG, model::DynamicPPL.Model, q, n_iterations::Int; objective=AdvancedVI.RepGradELBO( 10; entropy=AdvancedVI.ClosedFormEntropyZeroGradient() ), show_progress::Bool=PROGRESS[], optimizer=AdvancedVI.DoWG(), averager=AdvancedVI.PolynomialAveragi...
[ 295, 323 ]
function vi( rng::Random.AbstractRNG, model::DynamicPPL.Model, q, n_iterations::Int; objective=AdvancedVI.RepGradELBO( 10; entropy=AdvancedVI.ClosedFormEntropyZeroGradient() ), show_progress::Bool=PROGRESS[], optimizer=AdvancedVI.DoWG(), averager=AdvancedVI.PolynomialAveragin...