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": [ "DataStructures.jl", "src", "accumulator.jl" ], "ground_truth": "function Base.intersect!(a::Accumulator, b::Accumulator)\n for k in union(keys(a), keys(b)) # union not intersection as we want to check both multiplicities\n va = a[k]\n vb = b[k]\n va >= 0 || ...
230
241
DataStructures.jl
0
function Base.intersect!(a::Accumulator, b::Accumulator) for k in union(keys(a), keys(b)) # union not intersection as we want to check both multiplicities va = a[k] vb = b[k] va >= 0 || throw(MultiplicityException(k, va)) vb >= 0 || throw(MultiplicityException(k, vb)) a[k] =...
Base.intersect!(a::Accumulator, b::Accumulator)
[ 230, 241 ]
function Base.intersect!(a::Accumulator, b::Accumulator) for k in union(keys(a), keys(b)) # union not intersection as we want to check both multiplicities va = a[k] vb = b[k] va >= 0 || throw(MultiplicityException(k, va)) vb >= 0 || throw(MultiplicityException(k, vb)) a[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": [ "DataStructures.jl", "src", "avl_tree.jl" ], "ground_truth": "function left_rotate(z::AVLTreeNode)\n y = z.rightChild\n α = y.leftChild\n y.leftChild = z\n z.rightChild = α\n z.height = compute_height(z)\n y.height = compute_height(y)\n z.subsize = compute_subtr...
83
93
DataStructures.jl
1
function left_rotate(z::AVLTreeNode) y = z.rightChild α = y.leftChild y.leftChild = z z.rightChild = α z.height = compute_height(z) y.height = compute_height(y) z.subsize = compute_subtree_size(z) y.subsize = compute_subtree_size(y) return y end
left_rotate(z::AVLTreeNode)
[ 83, 93 ]
function left_rotate(z::AVLTreeNode) y = z.rightChild α = y.leftChild y.leftChild = z z.rightChild = α z.height = compute_height(z) y.height = compute_height(y) z.subsize = compute_subtree_size(z) y.subsize = compute_subtree_size(y) return y 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": [ "DataStructures.jl", "src", "avl_tree.jl" ], "ground_truth": "function right_rotate(z::AVLTreeNode)\n y = z.leftChild\n α = y.rightChild\n y.rightChild = z\n z.leftChild = α\n z.height = compute_height(z)\n y.height = compute_height(y)\n z.subsize = compute_subt...
100
110
DataStructures.jl
2
function right_rotate(z::AVLTreeNode) y = z.leftChild α = y.rightChild y.rightChild = z z.leftChild = α z.height = compute_height(z) y.height = compute_height(y) z.subsize = compute_subtree_size(z) y.subsize = compute_subtree_size(y) return y end
right_rotate(z::AVLTreeNode)
[ 100, 110 ]
function right_rotate(z::AVLTreeNode) y = z.leftChild α = y.rightChild y.rightChild = z z.leftChild = α z.height = compute_height(z) y.height = compute_height(y) z.subsize = compute_subtree_size(z) y.subsize = compute_subtree_size(y) return y 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": [ "DataStructures.jl", "src", "avl_tree.jl" ], "ground_truth": "function search_node(tree::AVLTree{K}, d::K) where K\n prev = nothing\n node = tree.root\n while node != nothing && node.data != nothing && node.data != d\n\n prev = node\n if d < node.data\n ...
124
138
DataStructures.jl
3
function search_node(tree::AVLTree{K}, d::K) where K prev = nothing node = tree.root while node != nothing && node.data != nothing && node.data != d prev = node if d < node.data node = node.leftChild else node = node.rightChild end end return...
search_node(tree::AVLTree{K}, d::K) where K
[ 124, 138 ]
function search_node(tree::AVLTree{K}, d::K) where K prev = nothing node = tree.root while node != nothing && node.data != nothing && node.data != d prev = node if d < node.data node = node.leftChild else node = node.rightChild end end return...
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": [ "DataStructures.jl", "src", "avl_tree.jl" ], "ground_truth": "function insert_node(node::AVLTreeNode{K}, key::K) where K\n if key < node.data\n node.leftChild = insert_node(node.leftChild, key)\n else\n node.rightChild = insert_node(node.rightChild, key)\n end...
162
192
DataStructures.jl
4
function insert_node(node::AVLTreeNode{K}, key::K) where K if key < node.data node.leftChild = insert_node(node.leftChild, key) else node.rightChild = insert_node(node.rightChild, key) end node.subsize = compute_subtree_size(node) node.height = compute_height(node) balance = get...
insert_node(node::AVLTreeNode{K}, key::K) where K
[ 162, 192 ]
function insert_node(node::AVLTreeNode{K}, key::K) where K if key < node.data node.leftChild = insert_node(node.leftChild, key) else node.rightChild = insert_node(node.rightChild, key) end node.subsize = compute_subtree_size(node) node.height = compute_height(node) balance = get...
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": [ "DataStructures.jl", "src", "avl_tree.jl" ], "ground_truth": "function delete_node!(node::AVLTreeNode{K}, key::K) where K\n if key < node.data\n node.leftChild = delete_node!(node.leftChild, key)\n elseif key > node.data\n node.rightChild = delete_node!(node.righ...
212
254
DataStructures.jl
5
function delete_node!(node::AVLTreeNode{K}, key::K) where K if key < node.data node.leftChild = delete_node!(node.leftChild, key) elseif key > node.data node.rightChild = delete_node!(node.rightChild, key) else if node.leftChild == nothing result = node.rightChild ...
delete_node!(node::AVLTreeNode{K}, key::K) where K
[ 212, 254 ]
function delete_node!(node::AVLTreeNode{K}, key::K) where K if key < node.data node.leftChild = delete_node!(node.leftChild, key) elseif key > node.data node.rightChild = delete_node!(node.rightChild, key) else if node.leftChild == nothing result = node.rightChild ...
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": [ "DataStructures.jl", "src", "avl_tree.jl" ], "ground_truth": "function sorted_rank(tree::AVLTree{K}, key::K) where K\n !haskey(tree, key) && throw(KeyError(key))\n node = tree.root\n rank = 0\n while node.data != key\n if (node.data < key)\n rank += (1 ...
290
304
DataStructures.jl
6
function sorted_rank(tree::AVLTree{K}, key::K) where K !haskey(tree, key) && throw(KeyError(key)) node = tree.root rank = 0 while node.data != key if (node.data < key) rank += (1 + get_subsize(node.leftChild)) node = node.rightChild else node = node.le...
sorted_rank(tree::AVLTree{K}, key::K) where K
[ 290, 304 ]
function sorted_rank(tree::AVLTree{K}, key::K) where K !haskey(tree, key) && throw(KeyError(key)) node = tree.root rank = 0 while node.data != key if (node.data < key) rank += (1 + get_subsize(node.leftChild)) node = node.rightChild else node = node.le...
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": [ "DataStructures.jl", "src", "avl_tree.jl" ], "ground_truth": "function Base.getindex(tree::AVLTree{K}, ind::Integer) where K\n @boundscheck (1 <= ind <= tree.count) || throw(BoundsError(\"$ind should be in between 1 and $(tree.count)\"))\n function traverse_tree(node::AVLTreeN...
329
345
DataStructures.jl
7
function Base.getindex(tree::AVLTree{K}, ind::Integer) where K @boundscheck (1 <= ind <= tree.count) || throw(BoundsError("$ind should be in between 1 and $(tree.count)")) function traverse_tree(node::AVLTreeNode_or_null, idx) if (node != nothing) L = get_subsize(node.leftChild) ...
Base.getindex(tree::AVLTree{K}, ind::Integer) where K
[ 329, 345 ]
function Base.getindex(tree::AVLTree{K}, ind::Integer) where K @boundscheck (1 <= ind <= tree.count) || throw(BoundsError("$ind should be in between 1 and $(tree.count)")) function traverse_tree(node::AVLTreeNode_or_null, idx) if (node != nothing) L = get_subsize(node.leftChild) ...
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": [ "DataStructures.jl", "src", "balanced_tree.jl" ], "ground_truth": "function Base.empty!(t::BalancedTree23)\n resize!(t.data,2)\n initializeData!(t.data)\n resize!(t.tree,1)\n initializeTree!(t.tree)\n t.depth = 1\n t.rootloc = 1\n empty!(t.freetreeinds)\n emp...
238
250
DataStructures.jl
8
function Base.empty!(t::BalancedTree23) resize!(t.data,2) initializeData!(t.data) resize!(t.tree,1) initializeTree!(t.tree) t.depth = 1 t.rootloc = 1 empty!(t.freetreeinds) empty!(t.freedatainds) empty!(t.useddatacells) push!(t.useddatacells, 1, 2) return nothing end
Base.empty!(t::BalancedTree23)
[ 238, 250 ]
function Base.empty!(t::BalancedTree23) resize!(t.data,2) initializeData!(t.data) resize!(t.tree,1) initializeTree!(t.tree) t.depth = 1 t.rootloc = 1 empty!(t.freetreeinds) empty!(t.freedatainds) empty!(t.useddatacells) push!(t.useddatacells, 1, 2) return nothing 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": [ "DataStructures.jl", "src", "balanced_tree.jl" ], "ground_truth": "function findkeyless(t::BalancedTree23, k)\n curnode = t.rootloc\n for depthcount = 1 : t.depth - 1\n @inbounds thisnode = t.tree[curnode]\n cmp = thisnode.child3 == 0 ?\n cmp2le_non...
292
309
DataStructures.jl
9
function findkeyless(t::BalancedTree23, k) curnode = t.rootloc for depthcount = 1 : t.depth - 1 @inbounds thisnode = t.tree[curnode] cmp = thisnode.child3 == 0 ? cmp2le_nonleaf(t.ord, thisnode, k) : cmp3le_nonleaf(t.ord, thisnode, k) curnode = cmp == 1 ? thi...
findkeyless(t::BalancedTree23, k)
[ 292, 309 ]
function findkeyless(t::BalancedTree23, k) curnode = t.rootloc for depthcount = 1 : t.depth - 1 @inbounds thisnode = t.tree[curnode] cmp = thisnode.child3 == 0 ? cmp2le_nonleaf(t.ord, thisnode, k) : cmp3le_nonleaf(t.ord, thisnode, k) curnode = cmp == 1 ? thi...
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": [ "DataStructures.jl", "src", "balanced_tree.jl" ], "ground_truth": "function Base.insert!(t::BalancedTree23{K,D,Ord}, k, d, allowdups::Bool) where {K,D,Ord <: Ordering}\n\n ## First we find the greatest data node that is <= k.\n leafind, exactfound = findkey(t, k)\n parent =...
358
520
DataStructures.jl
10
function Base.insert!(t::BalancedTree23{K,D,Ord}, k, d, allowdups::Bool) where {K,D,Ord <: Ordering} ## First we find the greatest data node that is <= k. leafind, exactfound = findkey(t, k) parent = t.data[leafind].parent ## The following code is necessary because in the case of a ## brand new tr...
Base.insert!(t::BalancedTree23{K,D,Ord}, k, d, allowdups::Bool) where {K,D,Ord <: Ordering}
[ 358, 520 ]
function Base.insert!(t::BalancedTree23{K,D,Ord}, k, d, allowdups::Bool) where {K,D,Ord <: Ordering} ## First we find the greatest data node that is <= k. leafind, exactfound = findkey(t, k) parent = t.data[leafind].parent ## The following code is necessary because in the case of a ## brand new tr...
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": [ "DataStructures.jl", "src", "balanced_tree.jl" ], "ground_truth": "function Base.delete!(t::BalancedTree23{K,D,Ord}, it::Int) where {K,D,Ord<:Ordering}\n\n ## Put the cell indexed by 'it' into the deletion list.\n ##\n ## Create the following data items maintained in the\n ...
655
984
DataStructures.jl
11
function Base.delete!(t::BalancedTree23{K,D,Ord}, it::Int) where {K,D,Ord<:Ordering} ## Put the cell indexed by 'it' into the deletion list. ## ## Create the following data items maintained in the ## upcoming loop. ## ## p is a tree-node ancestor of the deleted node ## The children of p are...
Base.delete!(t::BalancedTree23{K,D,Ord}, it::Int) where {K,D,Ord<:Ordering}
[ 655, 984 ]
function Base.delete!(t::BalancedTree23{K,D,Ord}, it::Int) where {K,D,Ord<:Ordering} ## Put the cell indexed by 'it' into the deletion list. ## ## Create the following data items maintained in the ## upcoming loop. ## ## p is a tree-node ancestor of the deleted node ## The children of p are...
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": [ "DataStructures.jl", "src", "circular_buffer.jl" ], "ground_truth": "function Base.resize!(cb::CircularBuffer, n::Integer)\n if n != capacity(cb)\n buf_new = Vector{eltype(cb)}(undef, n)\n len_new = min(length(cb), n)\n for i in 1:len_new\n @inboun...
243
257
DataStructures.jl
12
function Base.resize!(cb::CircularBuffer, n::Integer) if n != capacity(cb) buf_new = Vector{eltype(cb)}(undef, n) len_new = min(length(cb), n) for i in 1:len_new @inbounds buf_new[i] = cb[i] end cb.capacity = n cb.first = 1 cb.length = len_new ...
Base.resize!(cb::CircularBuffer, n::Integer)
[ 243, 257 ]
function Base.resize!(cb::CircularBuffer, n::Integer) if n != capacity(cb) buf_new = Vector{eltype(cb)}(undef, n) len_new = min(length(cb), n) for i in 1:len_new @inbounds buf_new[i] = cb[i] end cb.capacity = n cb.first = 1 cb.length = len_new ...
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": [ "DataStructures.jl", "src", "deque.jl" ], "ground_truth": "function Base.iterate(di::DequeIterator{T}, (cb, i) = (di.d.head, di.d.head.front)) where T\n i > cb.back && return nothing\n x = cb.data[i]\n\n i += 1\n if i > cb.back && !isrear(cb)\n cb = cb.next\n ...
141
152
DataStructures.jl
13
function Base.iterate(di::DequeIterator{T}, (cb, i) = (di.d.head, di.d.head.front)) where T i > cb.back && return nothing x = cb.data[i] i += 1 if i > cb.back && !isrear(cb) cb = cb.next i = 1 end return (x, (cb, i)) end
Base.iterate(di::DequeIterator{T}, (cb, i) = (di.d.head, di.d.head.front)) where T
[ 141, 152 ]
function Base.iterate(di::DequeIterator{T}, (cb, i) = (di.d.head, di.d.head.front)) where T i > cb.back && return nothing x = cb.data[i] i += 1 if i > cb.back && !isrear(cb) cb = cb.next i = 1 end return (x, (cb, i)) 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": [ "DataStructures.jl", "src", "deque.jl" ], "ground_truth": "function Base.iterate(di::Iterators.Reverse{<:Deque}, (cb, i) = (di.itr.rear, di.itr.rear.back))\n i < cb.front && return nothing\n x = cb.data[i]\n\n i -= 1\n # If we're past the beginning of a block, go to the ...
156
168
DataStructures.jl
14
function Base.iterate(di::Iterators.Reverse{<:Deque}, (cb, i) = (di.itr.rear, di.itr.rear.back)) i < cb.front && return nothing x = cb.data[i] i -= 1 # If we're past the beginning of a block, go to the previous one if i < cb.front && !ishead(cb) cb = cb.prev i = cb.back end ...
Base.iterate(di::Iterators.Reverse{<:Deque}, (cb, i) = (di.itr.rear, di.itr.rear.back))
[ 156, 168 ]
function Base.iterate(di::Iterators.Reverse{<:Deque}, (cb, i) = (di.itr.rear, di.itr.rear.back)) i < cb.front && return nothing x = cb.data[i] i -= 1 # If we're past the beginning of a block, go to the previous one if i < cb.front && !ishead(cb) cb = cb.prev i = cb.back 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": [ "DataStructures.jl", "src", "deque.jl" ], "ground_truth": "function Base.empty!(d::Deque{T}) where T\n # release all blocks except the head\n if d.nblocks > 1\n cb::DequeBlock{T} = d.rear\n while cb != d.head\n empty!(cb.data)\n cb = cb.prev...
212
230
DataStructures.jl
15
function Base.empty!(d::Deque{T}) where T # release all blocks except the head if d.nblocks > 1 cb::DequeBlock{T} = d.rear while cb != d.head empty!(cb.data) cb = cb.prev end end # clean the head block (but retain the block itself) reset!(d.head, 1) ...
Base.empty!(d::Deque{T}) where T
[ 212, 230 ]
function Base.empty!(d::Deque{T}) where T # release all blocks except the head if d.nblocks > 1 cb::DequeBlock{T} = d.rear while cb != d.head empty!(cb.data) cb = cb.prev end end # clean the head block (but retain the block itself) reset!(d.head, 1) ...
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": [ "DataStructures.jl", "src", "deque.jl" ], "ground_truth": "function Base.push!(d::Deque{T}, x) where T\n rear = d.rear\n\n if isempty(rear)\n rear.front = 1\n rear.back = 0\n end\n\n if rear.back < rear.capa\n @inbounds rear.data[rear.back += 1] = co...
238
258
DataStructures.jl
16
function Base.push!(d::Deque{T}, x) where T rear = d.rear if isempty(rear) rear.front = 1 rear.back = 0 end if rear.back < rear.capa @inbounds rear.data[rear.back += 1] = convert(T, x) else new_rear = rear_deque_block(T, d.blksize) new_rear.back = 1 ...
Base.push!(d::Deque{T}, x) where T
[ 238, 258 ]
function Base.push!(d::Deque{T}, x) where T rear = d.rear if isempty(rear) rear.front = 1 rear.back = 0 end if rear.back < rear.capa @inbounds rear.data[rear.back += 1] = convert(T, x) else new_rear = rear_deque_block(T, d.blksize) new_rear.back = 1 ...
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": [ "DataStructures.jl", "src", "deque.jl" ], "ground_truth": "function Base.pushfirst!(d::Deque{T}, x) where T\n head = d.head\n\n if isempty(head)\n n = head.capa\n head.front = n + 1\n head.back = n\n end\n\n if head.front > 1\n @inbounds head....
265
287
DataStructures.jl
17
function Base.pushfirst!(d::Deque{T}, x) where T head = d.head if isempty(head) n = head.capa head.front = n + 1 head.back = n end if head.front > 1 @inbounds head.data[head.front -= 1] = convert(T, x) else n::Int = d.blksize new_head = head_deque_bl...
Base.pushfirst!(d::Deque{T}, x) where T
[ 265, 287 ]
function Base.pushfirst!(d::Deque{T}, x) where T head = d.head if isempty(head) n = head.capa head.front = n + 1 head.back = n end if head.front > 1 @inbounds head.data[head.front -= 1] = convert(T, x) else n::Int = d.blksize new_head = head_deque_bl...
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": [ "DataStructures.jl", "src", "deque.jl" ], "ground_truth": "function Base.pop!(d::Deque{T}) where T\n isempty(d) && throw(ArgumentError(\"Deque must be non-empty\"))\n rear = d.rear\n @assert rear.back >= rear.front\n\n @inbounds x = rear.data[rear.back]\n Base._unseti...
294
313
DataStructures.jl
18
function Base.pop!(d::Deque{T}) where T isempty(d) && throw(ArgumentError("Deque must be non-empty")) rear = d.rear @assert rear.back >= rear.front @inbounds x = rear.data[rear.back] Base._unsetindex!(rear.data, rear.back) # see issue/884 rear.back -= 1 if rear.back < rear.front if ...
Base.pop!(d::Deque{T}) where T
[ 294, 313 ]
function Base.pop!(d::Deque{T}) where T isempty(d) && throw(ArgumentError("Deque must be non-empty")) rear = d.rear @assert rear.back >= rear.front @inbounds x = rear.data[rear.back] Base._unsetindex!(rear.data, rear.back) # see issue/884 rear.back -= 1 if rear.back < rear.front if ...
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": [ "DataStructures.jl", "src", "deque.jl" ], "ground_truth": "function Base.popfirst!(d::Deque{T}) where T\n isempty(d) && throw(ArgumentError(\"Deque must be non-empty\"))\n head = d.head\n @assert head.back >= head.front\n\n @inbounds x = head.data[head.front]\n Base._...
320
339
DataStructures.jl
19
function Base.popfirst!(d::Deque{T}) where T isempty(d) && throw(ArgumentError("Deque must be non-empty")) head = d.head @assert head.back >= head.front @inbounds x = head.data[head.front] Base._unsetindex!(head.data, head.front) # see issue/884 head.front += 1 if head.back < head.front ...
Base.popfirst!(d::Deque{T}) where T
[ 320, 339 ]
function Base.popfirst!(d::Deque{T}) where T isempty(d) && throw(ArgumentError("Deque must be non-empty")) head = d.head @assert head.back >= head.front @inbounds x = head.data[head.front] Base._unsetindex!(head.data, head.front) # see issue/884 head.front += 1 if head.back < head.front ...
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": [ "DataStructures.jl", "src", "dibit_vector.jl" ], "ground_truth": "function DiBitVector(n::Integer, v::Integer)\n if Int(n) < 0\n throw(ArgumentError(\"n ($n) must be greater than or equal to zero\"))\n end\n if !(Int(v) in 0:3)\n throw(Argu...
15
27
DataStructures.jl
20
function DiBitVector(n::Integer, v::Integer) if Int(n) < 0 throw(ArgumentError("n ($n) must be greater than or equal to zero")) end if !(Int(v) in 0:3) throw(ArgumentError("v ($v) must be in 0:3")) end fv = (0x0000000000000000, 0x5555555555555555, ...
DiBitVector(n::Integer, v::Integer)
[ 15, 27 ]
function DiBitVector(n::Integer, v::Integer) if Int(n) < 0 throw(ArgumentError("n ($n) must be greater than or equal to zero")) end if !(Int(v) in 0:3) throw(ArgumentError("v ($v) must be in 0:3")) end fv = (0x0000000000000000, 0x5555555555555555, ...
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": [ "DataStructures.jl", "src", "dict_support.jl" ], "ground_truth": "function not_iterator_of_pairs(kv::T) where T\n # if the object is not iterable, return true, else check the eltype of the iteration\n Base.isiterable(T) || return true \n # else, check if we can check `eltyp...
3
16
DataStructures.jl
21
function not_iterator_of_pairs(kv::T) where T # if the object is not iterable, return true, else check the eltype of the iteration Base.isiterable(T) || return true # else, check if we can check `eltype`: if Base.IteratorEltype(kv) isa Base.HasEltype typ = eltype(kv) if !(typ == Any) ...
not_iterator_of_pairs(kv::T) where T
[ 3, 16 ]
function not_iterator_of_pairs(kv::T) where T # if the object is not iterable, return true, else check the eltype of the iteration Base.isiterable(T) || return true # else, check if we can check `eltype`: if Base.IteratorEltype(kv) isa Base.HasEltype typ = eltype(kv) if !(typ == Any) ...
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": [ "DataStructures.jl", "src", "disjoint_set.jl" ], "ground_truth": "function root_union!(s::IntDisjointSet{T}, x::T, y::T) where {T<:Integer}\n parents = s.parents\n rks = s.ranks\n @inbounds xrank = rks[x]\n @inbounds yrank = rks[y]\n\n if xrank < yrank\n x, y =...
103
117
DataStructures.jl
22
function root_union!(s::IntDisjointSet{T}, x::T, y::T) where {T<:Integer} parents = s.parents rks = s.ranks @inbounds xrank = rks[x] @inbounds yrank = rks[y] if xrank < yrank x, y = y, x elseif xrank == yrank rks[x] += one(T) end @inbounds parents[y] = x s.ngroups -=...
root_union!(s::IntDisjointSet{T}, x::T, y::T) where {T<:Integer}
[ 103, 117 ]
function root_union!(s::IntDisjointSet{T}, x::T, y::T) where {T<:Integer} parents = s.parents rks = s.ranks @inbounds xrank = rks[x] @inbounds yrank = rks[y] if xrank < yrank x, y = y, x elseif xrank == yrank rks[x] += one(T) end @inbounds parents[y] = x s.ngroups -=...
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": [ "DataStructures.jl", "src", "disjoint_set.jl" ], "ground_truth": "function DisjointSet{T}(xs) where T # xs must be iterable\n imap = Dict{T,Int}()\n rmap = Vector{T}()\n n = length(xs)::Int\n sizehint!(imap, n)\n sizehint!(rmap, n)\n id =...
150
162
DataStructures.jl
23
function DisjointSet{T}(xs) where T # xs must be iterable imap = Dict{T,Int}() rmap = Vector{T}() n = length(xs)::Int sizehint!(imap, n) sizehint!(rmap, n) id = 0 for x in xs imap[x] = (id += 1) push!(rmap,x) end return n...
DisjointSet{T}(xs) where T
[ 150, 162 ]
function DisjointSet{T}(xs) where T # xs must be iterable imap = Dict{T,Int}() rmap = Vector{T}() n = length(xs)::Int sizehint!(imap, n) sizehint!(rmap, n) id = 0 for x in xs imap[x] = (id += 1) push!(rmap,x) end return n...
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": [ "DataStructures.jl", "src", "heaps.jl" ], "ground_truth": "function nextreme(ord::Base.Ordering, n::Int, arr::AbstractVector{T}) where T\n if n <= 0\n return T[] # sort(arr)[1:n] returns [] for n <= 0\n elseif n >= length(arr)\n return sort(arr, order = ord)\n ...
111
131
DataStructures.jl
24
function nextreme(ord::Base.Ordering, n::Int, arr::AbstractVector{T}) where T if n <= 0 return T[] # sort(arr)[1:n] returns [] for n <= 0 elseif n >= length(arr) return sort(arr, order = ord) end rev = Base.ReverseOrdering(ord) buffer = heapify(arr[1:n], rev) for i = n + 1 : l...
nextreme(ord::Base.Ordering, n::Int, arr::AbstractVector{T}) where T
[ 111, 131 ]
function nextreme(ord::Base.Ordering, n::Int, arr::AbstractVector{T}) where T if n <= 0 return T[] # sort(arr)[1:n] returns [] for n <= 0 elseif n >= length(arr) return sort(arr, order = ord) end rev = Base.ReverseOrdering(ord) buffer = heapify(arr[1:n], rev) for i = n + 1 : l...
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": [ "DataStructures.jl", "src", "int_set.jl" ], "ground_truth": "function findnextidx(s::IntSet, i::Int, invert=false)\n if s.inverse ⊻ invert\n # i+1 could rollover causing a BoundsError in findnext/findnextnot\n nextidx = i == typemax(Int) ? 0 : something(findnextnot(...
159
169
DataStructures.jl
25
function findnextidx(s::IntSet, i::Int, invert=false) if s.inverse ⊻ invert # i+1 could rollover causing a BoundsError in findnext/findnextnot nextidx = i == typemax(Int) ? 0 : something(findnextnot(s.bits, i+1), 0) # Extend indices beyond the length of the bits since it is inverted ...
findnextidx(s::IntSet, i::Int, invert=false)
[ 159, 169 ]
function findnextidx(s::IntSet, i::Int, invert=false) if s.inverse ⊻ invert # i+1 could rollover causing a BoundsError in findnext/findnextnot nextidx = i == typemax(Int) ? 0 : something(findnextnot(s.bits, i+1), 0) # Extend indices beyond the length of the bits since it is inverted ...
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": [ "DataStructures.jl", "src", "multi_dict.jl" ], "ground_truth": "function Base.pop!(d::MultiDict, key, default)\n vs = get(d, key, Base.secret_table_token)\n if vs === Base.secret_table_token\n if default !== Base.secret_table_token\n return default\n e...
64
76
DataStructures.jl
26
function Base.pop!(d::MultiDict, key, default) vs = get(d, key, Base.secret_table_token) if vs === Base.secret_table_token if default !== Base.secret_table_token return default else throw(KeyError(key)) end end v = pop!(vs) (length(vs) == 0) && delete!...
Base.pop!(d::MultiDict, key, default)
[ 64, 76 ]
function Base.pop!(d::MultiDict, key, default) vs = get(d, key, Base.secret_table_token) if vs === Base.secret_table_token if default !== Base.secret_table_token return default else throw(KeyError(key)) end end v = pop!(vs) (length(vs) == 0) && delete!...
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": [ "DataStructures.jl", "src", "multi_dict.jl" ], "ground_truth": "function Base.iterate(e::EnumerateAll)\n V = eltype(eltype(values(e.d)))\n vs = V[]\n dstate = iterate(e.d.d)\n vstate = iterate(vs)\n dstate === nothing || vstate === nothing && return nothing\n k = n...
98
112
DataStructures.jl
27
function Base.iterate(e::EnumerateAll) V = eltype(eltype(values(e.d))) vs = V[] dstate = iterate(e.d.d) vstate = iterate(vs) dstate === nothing || vstate === nothing && return nothing k = nothing while vstate === nothing ((k, vs), dst) = dstate dstate = iterate(e.d.d, dst) ...
Base.iterate(e::EnumerateAll)
[ 98, 112 ]
function Base.iterate(e::EnumerateAll) V = eltype(eltype(values(e.d))) vs = V[] dstate = iterate(e.d.d) vstate = iterate(vs) dstate === nothing || vstate === nothing && return nothing k = nothing while vstate === nothing ((k, vs), dst) = dstate dstate = iterate(e.d.d, dst) ...
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": [ "DataStructures.jl", "src", "multi_dict.jl" ], "ground_truth": "function Base.iterate(e::EnumerateAll, s)\n dstate, k, vs, vstate = s\n dstate === nothing || vstate === nothing && return nothing\n while vstate === nothing\n ((k, vs), dst) = dstate\n dstate = i...
114
124
DataStructures.jl
28
function Base.iterate(e::EnumerateAll, s) dstate, k, vs, vstate = s dstate === nothing || vstate === nothing && return nothing while vstate === nothing ((k, vs), dst) = dstate dstate = iterate(e.d.d, dst) vstate = iterate(vs) end v, vst = vstate return ((k, v), (dstate, k...
Base.iterate(e::EnumerateAll, s)
[ 114, 124 ]
function Base.iterate(e::EnumerateAll, s) dstate, k, vs, vstate = s dstate === nothing || vstate === nothing && return nothing while vstate === nothing ((k, vs), dst) = dstate dstate = iterate(e.d.d, dst) vstate = iterate(vs) end v, vst = vstate return ((k, v), (dstate, 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": [ "DataStructures.jl", "src", "mutable_list.jl" ], "ground_truth": "function Base.getindex(l::MutableLinkedList{T}, r::UnitRange) where T\n @boundscheck 0 < first(r) < last(r) <= l.len || throw(BoundsError(l, r))\n l2 = MutableLinkedList{T}()\n node = l.node\n for i in 1:f...
127
141
DataStructures.jl
29
function Base.getindex(l::MutableLinkedList{T}, r::UnitRange) where T @boundscheck 0 < first(r) < last(r) <= l.len || throw(BoundsError(l, r)) l2 = MutableLinkedList{T}() node = l.node for i in 1:first(r) node = node.next end len = length(r) for j in 1:len push!(l2, node.data...
Base.getindex(l::MutableLinkedList{T}, r::UnitRange) where T
[ 127, 141 ]
function Base.getindex(l::MutableLinkedList{T}, r::UnitRange) where T @boundscheck 0 < first(r) < last(r) <= l.len || throw(BoundsError(l, r)) l2 = MutableLinkedList{T}() node = l.node for i in 1:first(r) node = node.next end len = length(r) for j in 1:len push!(l2, node.data...
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": [ "DataStructures.jl", "src", "mutable_list.jl" ], "ground_truth": "function Base.append!(l1::MutableLinkedList{T}, l2::MutableLinkedList{T}) where T\n l1.node.prev.next = l2.node.next # l1's last's next is now l2's first\n l2.node.prev.next = l1.node # l2's last's next is now l...
153
164
DataStructures.jl
30
function Base.append!(l1::MutableLinkedList{T}, l2::MutableLinkedList{T}) where T l1.node.prev.next = l2.node.next # l1's last's next is now l2's first l2.node.prev.next = l1.node # l2's last's next is now l1.node l2.node.next.prev = l1.node.prev # l2's first's prev is now l1's last l1.node.prev = ...
Base.append!(l1::MutableLinkedList{T}, l2::MutableLinkedList{T}) where T
[ 153, 164 ]
function Base.append!(l1::MutableLinkedList{T}, l2::MutableLinkedList{T}) where T l1.node.prev.next = l2.node.next # l1's last's next is now l2's first l2.node.prev.next = l1.node # l2's last's next is now l1.node l2.node.next.prev = l1.node.prev # l2's first's prev is now l1's last l1.node.prev = ...
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": [ "DataStructures.jl", "src", "mutable_list.jl" ], "ground_truth": "function Base.delete!(l::MutableLinkedList, idx::Int)\n @boundscheck 0 < idx <= l.len || throw(BoundsError(l, idx))\n node = l.node\n for i = 1:idx\n node = node.next\n end\n prev = node.prev\n ...
175
187
DataStructures.jl
31
function Base.delete!(l::MutableLinkedList, idx::Int) @boundscheck 0 < idx <= l.len || throw(BoundsError(l, idx)) node = l.node for i = 1:idx node = node.next end prev = node.prev next = node.next prev.next = next next.prev = prev l.len -= 1 return l end
Base.delete!(l::MutableLinkedList, idx::Int)
[ 175, 187 ]
function Base.delete!(l::MutableLinkedList, idx::Int) @boundscheck 0 < idx <= l.len || throw(BoundsError(l, idx)) node = l.node for i = 1:idx node = node.next end prev = node.prev next = node.next prev.next = next next.prev = prev l.len -= 1 return l 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": [ "DataStructures.jl", "src", "mutable_list.jl" ], "ground_truth": "function Base.delete!(l::MutableLinkedList, r::UnitRange)\n @boundscheck 0 < first(r) < last(r) <= l.len || throw(BoundsError(l, r))\n node = l.node\n for i in 1:first(r)\n node = node.next\n end\n ...
189
205
DataStructures.jl
32
function Base.delete!(l::MutableLinkedList, r::UnitRange) @boundscheck 0 < first(r) < last(r) <= l.len || throw(BoundsError(l, r)) node = l.node for i in 1:first(r) node = node.next end prev = node.prev len = length(r) for j in 1:len node = node.next end next = node ...
Base.delete!(l::MutableLinkedList, r::UnitRange)
[ 189, 205 ]
function Base.delete!(l::MutableLinkedList, r::UnitRange) @boundscheck 0 < first(r) < last(r) <= l.len || throw(BoundsError(l, r)) node = l.node for i in 1:first(r) node = node.next end prev = node.prev len = length(r) for j in 1:len node = node.next end next = node ...
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": [ "DataStructures.jl", "src", "ordered_robin_dict.jl" ], "ground_truth": "function Base.setindex!(h::OrderedRobinDict{K, V}, v0, key0) where {K,V}\n key = convert(K, key0)\n v = convert(V, v0)\n index = get(h.dict, key, -2)\n\n if index < 0\n _setindex!(h, v0, key0)...
125
141
DataStructures.jl
33
function Base.setindex!(h::OrderedRobinDict{K, V}, v0, key0) where {K,V} key = convert(K, key0) v = convert(V, v0) index = get(h.dict, key, -2) if index < 0 _setindex!(h, v0, key0) else @assert haskey(h, key0) @inbounds orig_v = h.vals[index] !isequal(orig_v, v0) && ...
Base.setindex!(h::OrderedRobinDict{K, V}, v0, key0) where {K,V}
[ 125, 141 ]
function Base.setindex!(h::OrderedRobinDict{K, V}, v0, key0) where {K,V} key = convert(K, key0) v = convert(V, v0) index = get(h.dict, key, -2) if index < 0 _setindex!(h, v0, key0) else @assert haskey(h, key0) @inbounds orig_v = h.vals[index] !isequal(orig_v, v0) && ...
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": [ "DataStructures.jl", "src", "ordered_robin_dict.jl" ], "ground_truth": "function rehash!(h::OrderedRobinDict{K, V}) where {K, V}\n keys = h.keys\n vals = h.vals\n hk = Vector{K}()\n hv = Vector{V}()\n\n for (idx, (k, v)) in enumerate(zip(keys, vals))\n if get(h...
151
171
DataStructures.jl
34
function rehash!(h::OrderedRobinDict{K, V}) where {K, V} keys = h.keys vals = h.vals hk = Vector{K}() hv = Vector{V}() for (idx, (k, v)) in enumerate(zip(keys, vals)) if get(h.dict, k, -1) == idx push!(hk, k) push!(hv, v) end end h.keys = hk h.va...
rehash!(h::OrderedRobinDict{K, V}) where {K, V}
[ 151, 171 ]
function rehash!(h::OrderedRobinDict{K, V}) where {K, V} keys = h.keys vals = h.vals hk = Vector{K}() hv = Vector{V}() for (idx, (k, v)) in enumerate(zip(keys, vals)) if get(h.dict, k, -1) == idx push!(hk, k) push!(hv, v) end end h.keys = hk h.va...
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": [ "DataStructures.jl", "src", "ordered_robin_dict.jl" ], "ground_truth": "function Base.sizehint!(d::OrderedRobinDict, newsz)\n oldsz = length(d)\n # grow at least 25%\n if newsz < (oldsz*5)>>2\n return d\n end\n sizehint!(d.keys, newsz)\n sizehint!(d.vals, ne...
173
183
DataStructures.jl
35
function Base.sizehint!(d::OrderedRobinDict, newsz) oldsz = length(d) # grow at least 25% if newsz < (oldsz*5)>>2 return d end sizehint!(d.keys, newsz) sizehint!(d.vals, newsz) sizehint!(d.dict, newsz) return d end
Base.sizehint!(d::OrderedRobinDict, newsz)
[ 173, 183 ]
function Base.sizehint!(d::OrderedRobinDict, newsz) oldsz = length(d) # grow at least 25% if newsz < (oldsz*5)>>2 return d end sizehint!(d.keys, newsz) sizehint!(d.vals, newsz) sizehint!(d.dict, newsz) return d 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": [ "DataStructures.jl", "src", "ordered_robin_dict.jl" ], "ground_truth": "function Base.pop!(h::OrderedRobinDict)\n check_for_rehash(h) && rehash!(h)\n index = length(h.keys)\n while (index > 0)\n isslotfilled(h, index) && break\n index -= 1\n end\n index ...
343
353
DataStructures.jl
36
function Base.pop!(h::OrderedRobinDict) check_for_rehash(h) && rehash!(h) index = length(h.keys) while (index > 0) isslotfilled(h, index) && break index -= 1 end index == 0 && rehash!(h) @inbounds key = h.keys[index] return key => _pop!(h, index) end
Base.pop!(h::OrderedRobinDict)
[ 343, 353 ]
function Base.pop!(h::OrderedRobinDict) check_for_rehash(h) && rehash!(h) index = length(h.keys) while (index > 0) isslotfilled(h, index) && break index -= 1 end index == 0 && rehash!(h) @inbounds key = h.keys[index] return key => _pop!(h, index) 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": [ "DataStructures.jl", "src", "priorityqueue.jl" ], "ground_truth": "function PriorityQueue{K,V,O}(o::O, itr) where {K,V,O<:Ordering}\n xs = Vector{Pair{K,V}}(undef, length(itr))\n index = Dict{K, Int}()\n for (i, (k, v)) in enumerate(itr)\n xs[i] = Pai...
49
67
DataStructures.jl
37
function PriorityQueue{K,V,O}(o::O, itr) where {K,V,O<:Ordering} xs = Vector{Pair{K,V}}(undef, length(itr)) index = Dict{K, Int}() for (i, (k, v)) in enumerate(itr) xs[i] = Pair{K,V}(k, v) if haskey(index, k) throw(ArgumentError("PriorityQueue keys must be...
PriorityQueue{K,V,O}(o::O, itr) where {K,V,O<:Ordering}
[ 49, 67 ]
function PriorityQueue{K,V,O}(o::O, itr) where {K,V,O<:Ordering} xs = Vector{Pair{K,V}}(undef, length(itr)) index = Dict{K, Int}() for (i, (k, v)) in enumerate(itr) xs[i] = Pair{K,V}(k, v) if haskey(index, k) throw(ArgumentError("PriorityQueue keys must be...
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": [ "DataStructures.jl", "src", "priorityqueue.jl" ], "ground_truth": "function Base.setindex!(pq::PriorityQueue{K, V}, value, key) where {K,V}\n i = get(pq.index, key, 0)\n if i != 0\n @inbounds oldvalue = pq.xs[i].second\n pq.xs[i] = Pair{K,V}(key, value)\n ...
237
251
DataStructures.jl
38
function Base.setindex!(pq::PriorityQueue{K, V}, value, key) where {K,V} i = get(pq.index, key, 0) if i != 0 @inbounds oldvalue = pq.xs[i].second pq.xs[i] = Pair{K,V}(key, value) if lt(pq.o, oldvalue, value) percolate_down!(pq, i) else percolate_up!(pq, i)...
Base.setindex!(pq::PriorityQueue{K, V}, value, key) where {K,V}
[ 237, 251 ]
function Base.setindex!(pq::PriorityQueue{K, V}, value, key) where {K,V} i = get(pq.index, key, 0) if i != 0 @inbounds oldvalue = pq.xs[i].second pq.xs[i] = Pair{K,V}(key, value) if lt(pq.o, oldvalue, value) percolate_down!(pq, i) else percolate_up!(pq, i)...
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": [ "DataStructures.jl", "src", "priorityqueue.jl" ], "ground_truth": "function Base.push!(pq::PriorityQueue{K,V}, pair::Pair{K,V}) where {K,V}\n key = pair.first\n if haskey(pq, key)\n throw(ArgumentError(\"PriorityQueue keys must be unique\"))\n end\n push!(pq.xs, p...
277
287
DataStructures.jl
39
function Base.push!(pq::PriorityQueue{K,V}, pair::Pair{K,V}) where {K,V} key = pair.first if haskey(pq, key) throw(ArgumentError("PriorityQueue keys must be unique")) end push!(pq.xs, pair) pq.index[key] = length(pq) percolate_up!(pq, length(pq)) return pq end
Base.push!(pq::PriorityQueue{K,V}, pair::Pair{K,V}) where {K,V}
[ 277, 287 ]
function Base.push!(pq::PriorityQueue{K,V}, pair::Pair{K,V}) where {K,V} key = pair.first if haskey(pq, key) throw(ArgumentError("PriorityQueue keys must be unique")) end push!(pq.xs, pair) pq.index[key] = length(pq) percolate_up!(pq, length(pq)) return pq 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": [ "DataStructures.jl", "src", "priorityqueue.jl" ], "ground_truth": "function Base.popfirst!(pq::PriorityQueue)\n x = pq.xs[1]\n y = pop!(pq.xs)\n if !isempty(pq)\n @inbounds pq.xs[1] = y\n pq.index[y.first] = 1\n percolate_down!(pq, 1)\n end\n dele...
314
324
DataStructures.jl
40
function Base.popfirst!(pq::PriorityQueue) x = pq.xs[1] y = pop!(pq.xs) if !isempty(pq) @inbounds pq.xs[1] = y pq.index[y.first] = 1 percolate_down!(pq, 1) end delete!(pq.index, x.first) return x end
Base.popfirst!(pq::PriorityQueue)
[ 314, 324 ]
function Base.popfirst!(pq::PriorityQueue) x = pq.xs[1] y = pop!(pq.xs) if !isempty(pq) @inbounds pq.xs[1] = y pq.index[y.first] = 1 percolate_down!(pq, 1) end delete!(pq.index, x.first) return x 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": [ "DataStructures.jl", "src", "red_black_tree.jl" ], "ground_truth": "function search_node(tree::RBTree{K}, d::K) where K\n node = tree.root\n while node !== tree.nil && d != node.data\n if d < node.data\n node = node.leftChild\n else\n node =...
54
64
DataStructures.jl
41
function search_node(tree::RBTree{K}, d::K) where K node = tree.root while node !== tree.nil && d != node.data if d < node.data node = node.leftChild else node = node.rightChild end end return node end
search_node(tree::RBTree{K}, d::K) where K
[ 54, 64 ]
function search_node(tree::RBTree{K}, d::K) where K node = tree.root while node !== tree.nil && d != node.data if d < node.data node = node.leftChild else node = node.rightChild end end return node 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": [ "DataStructures.jl", "src", "red_black_tree.jl" ], "ground_truth": "function Base.insert!(tree::RBTree{K}, d::K) where K\n # if the key exists in the tree, no need to insert\n haskey(tree, d) && return tree\n\n # insert, if not present in the tree\n node = RBTreeNode{K}(...
211
230
DataStructures.jl
42
function Base.insert!(tree::RBTree{K}, d::K) where K # if the key exists in the tree, no need to insert haskey(tree, d) && return tree # insert, if not present in the tree node = RBTreeNode{K}(d) node.leftChild = node.rightChild = tree.nil insert_node!(tree, node) if node.parent == nothin...
Base.insert!(tree::RBTree{K}, d::K) where K
[ 211, 230 ]
function Base.insert!(tree::RBTree{K}, d::K) where K # if the key exists in the tree, no need to insert haskey(tree, d) && return tree # insert, if not present in the tree node = RBTreeNode{K}(d) node.leftChild = node.rightChild = tree.nil insert_node!(tree, node) if node.parent == nothin...
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": [ "DataStructures.jl", "src", "red_black_tree.jl" ], "ground_truth": "function delete_fix(tree::RBTree, node::Union{RBTreeNode, Nothing})\n while node != tree.root && !node.color\n if node == node.parent.leftChild\n sibling = node.parent.rightChild\n i...
247
305
DataStructures.jl
43
function delete_fix(tree::RBTree, node::Union{RBTreeNode, Nothing}) while node != tree.root && !node.color if node == node.parent.leftChild sibling = node.parent.rightChild if sibling.color sibling.color = false node.parent.color = true ...
delete_fix(tree::RBTree, node::Union{RBTreeNode, Nothing})
[ 247, 305 ]
function delete_fix(tree::RBTree, node::Union{RBTreeNode, Nothing}) while node != tree.root && !node.color if node == node.parent.leftChild sibling = node.parent.rightChild if sibling.color sibling.color = false node.parent.color = true ...
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": [ "DataStructures.jl", "src", "red_black_tree.jl" ], "ground_truth": "function Base.delete!(tree::RBTree{K}, d::K) where K\n z = tree.nil\n node = tree.root\n\n while node !== tree.nil\n if node.data == d\n z = node\n end\n\n if d < node.data\n...
341
390
DataStructures.jl
44
function Base.delete!(tree::RBTree{K}, d::K) where K z = tree.nil node = tree.root while node !== tree.nil if node.data == d z = node end if d < node.data node = node.leftChild else node = node.rightChild end end (z === t...
Base.delete!(tree::RBTree{K}, d::K) where K
[ 341, 390 ]
function Base.delete!(tree::RBTree{K}, d::K) where K z = tree.nil node = tree.root while node !== tree.nil if node.data == d z = node end if d < node.data node = node.leftChild else node = node.rightChild end end (z === t...
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": [ "DataStructures.jl", "src", "red_black_tree.jl" ], "ground_truth": "function Base.getindex(tree::RBTree{K}, ind) where K\n @boundscheck (1 <= ind <= tree.count) || throw(ArgumentError(\"$ind should be in between 1 and $(tree.count)\"))\n function traverse_tree_inorder(node::RB...
399
412
DataStructures.jl
45
function Base.getindex(tree::RBTree{K}, ind) where K @boundscheck (1 <= ind <= tree.count) || throw(ArgumentError("$ind should be in between 1 and $(tree.count)")) function traverse_tree_inorder(node::RBTreeNode{K}) where K if (node !== tree.nil) left = traverse_tree_inorder(node.leftChild) ...
Base.getindex(tree::RBTree{K}, ind) where K
[ 399, 412 ]
function Base.getindex(tree::RBTree{K}, ind) where K @boundscheck (1 <= ind <= tree.count) || throw(ArgumentError("$ind should be in between 1 and $(tree.count)")) function traverse_tree_inorder(node::RBTreeNode{K}) where K if (node !== tree.nil) left = traverse_tree_inorder(node.leftChild) ...
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": [ "DataStructures.jl", "src", "robin_dict.jl" ], "ground_truth": "function rh_insert!(h::RobinDict{K, V}, key::K, val::V) where {K, V}\n sz = length(h.keys)\n (h.count > ROBIN_DICT_LOAD_FACTOR * sz) && rehash!(h, sz<<2)\n\n # table full\n @assert h.count != length(h.keys)\...
97
148
DataStructures.jl
46
function rh_insert!(h::RobinDict{K, V}, key::K, val::V) where {K, V} sz = length(h.keys) (h.count > ROBIN_DICT_LOAD_FACTOR * sz) && rehash!(h, sz<<2) # table full @assert h.count != length(h.keys) ckey, cval, chash = key, val, hash_key(key) sz = length(h.keys) index_init = desired_index(ch...
rh_insert!(h::RobinDict{K, V}, key::K, val::V) where {K, V}
[ 97, 148 ]
function rh_insert!(h::RobinDict{K, V}, key::K, val::V) where {K, V} sz = length(h.keys) (h.count > ROBIN_DICT_LOAD_FACTOR * sz) && rehash!(h, sz<<2) # table full @assert h.count != length(h.keys) ckey, cval, chash = key, val, hash_key(key) sz = length(h.keys) index_init = desired_index(ch...
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": [ "DataStructures.jl", "src", "robin_dict.jl" ], "ground_truth": "function rh_insert_for_rehash!(h_new::RobinDict{K, V}, key::K, val::V, hash::UInt32) where {K, V}\n # table full\n @assert h_new.count != length(h_new.keys)\n\n ckey, cval, chash = key, val, hash\n sz = leng...
150
193
DataStructures.jl
47
function rh_insert_for_rehash!(h_new::RobinDict{K, V}, key::K, val::V, hash::UInt32) where {K, V} # table full @assert h_new.count != length(h_new.keys) ckey, cval, chash = key, val, hash sz = length(h_new.keys) index_init = desired_index(chash, sz) index_curr = index_init probe_distance =...
rh_insert_for_rehash!(h_new::RobinDict{K, V}, key::K, val::V, hash::UInt32) where {K, V}
[ 150, 193 ]
function rh_insert_for_rehash!(h_new::RobinDict{K, V}, key::K, val::V, hash::UInt32) where {K, V} # table full @assert h_new.count != length(h_new.keys) ckey, cval, chash = key, val, hash sz = length(h_new.keys) index_init = desired_index(chash, sz) index_curr = index_init probe_distance =...
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": [ "DataStructures.jl", "src", "robin_dict.jl" ], "ground_truth": "function rehash!(h::RobinDict{K,V}, newsz = length(h.keys)) where {K, V}\n oldk = h.keys\n oldv = h.vals\n oldh = h.hashes\n sz = length(oldk)\n newsz = _tablesz(newsz)\n if h.count == 0\n resiz...
196
226
DataStructures.jl
48
function rehash!(h::RobinDict{K,V}, newsz = length(h.keys)) where {K, V} oldk = h.keys oldv = h.vals oldh = h.hashes sz = length(oldk) newsz = _tablesz(newsz) if h.count == 0 resize!(h.keys, newsz) resize!(h.vals, newsz) resize!(h.hashes, newsz) fill!(h.hashes, 0)...
rehash!(h::RobinDict{K,V}, newsz = length(h.keys)) where {K, V}
[ 196, 226 ]
function rehash!(h::RobinDict{K,V}, newsz = length(h.keys)) where {K, V} oldk = h.keys oldv = h.vals oldh = h.hashes sz = length(oldk) newsz = _tablesz(newsz) if h.count == 0 resize!(h.keys, newsz) resize!(h.vals, newsz) resize!(h.hashes, newsz) fill!(h.hashes, 0)...
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": [ "DataStructures.jl", "src", "robin_dict.jl" ], "ground_truth": "function Base.empty!(h::RobinDict{K,V}) where {K, V}\n sz = length(h.keys)\n empty!(h.hashes)\n empty!(h.keys)\n empty!(h.vals)\n resize!(h.keys, sz)\n resize!(h.vals, sz)\n resize!(h.hashes, sz)\n ...
274
286
DataStructures.jl
49
function Base.empty!(h::RobinDict{K,V}) where {K, V} sz = length(h.keys) empty!(h.hashes) empty!(h.keys) empty!(h.vals) resize!(h.keys, sz) resize!(h.vals, sz) resize!(h.hashes, sz) fill!(h.hashes, 0) h.count = 0 h.idxfloor = 0 return h end
Base.empty!(h::RobinDict{K,V}) where {K, V}
[ 274, 286 ]
function Base.empty!(h::RobinDict{K,V}) where {K, V} sz = length(h.keys) empty!(h.hashes) empty!(h.keys) empty!(h.vals) resize!(h.keys, sz) resize!(h.vals, sz) resize!(h.hashes, sz) fill!(h.hashes, 0) h.count = 0 h.idxfloor = 0 return h 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": [ "DataStructures.jl", "src", "robin_dict.jl" ], "ground_truth": "function rh_delete!(h::RobinDict{K, V}, index) where {K, V}\n @assert index > 0\n\n # this assumes that there is a key/value present in the dictionary at index\n index0 = index\n sz = length(h.keys)\n @in...
459
494
DataStructures.jl
50
function rh_delete!(h::RobinDict{K, V}, index) where {K, V} @assert index > 0 # this assumes that there is a key/value present in the dictionary at index index0 = index sz = length(h.keys) @inbounds while true index0 = (index0 & (sz - 1)) + 1 if isslotempty(h, index0) || calculate_d...
rh_delete!(h::RobinDict{K, V}, index) where {K, V}
[ 459, 494 ]
function rh_delete!(h::RobinDict{K, V}, index) where {K, V} @assert index > 0 # this assumes that there is a key/value present in the dictionary at index index0 = index sz = length(h.keys) @inbounds while true index0 = (index0 & (sz - 1)) + 1 if isslotempty(h, index0) || calculate_d...
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": [ "DataStructures.jl", "src", "sorted_set.jl" ], "ground_truth": "function Base.iterate(twoss::IntersectTwoSortedSets,\n state = TwoSortedSets_State(firstindex(twoss.m1),\n firstindex(twoss.m2)))\n m1 = twoss.m1\...
395
418
DataStructures.jl
51
function Base.iterate(twoss::IntersectTwoSortedSets, state = TwoSortedSets_State(firstindex(twoss.m1), firstindex(twoss.m2))) m1 = twoss.m1 m2 = twoss.m2 ord = orderobject(m1) p1 = state.p1 p2 = state.p2 while p1 != pastends...
Base.iterate(twoss::IntersectTwoSortedSets, state = TwoSortedSets_State(firstindex(twoss.m1), firstindex(twoss.m2)))
[ 395, 418 ]
function Base.iterate(twoss::IntersectTwoSortedSets, state = TwoSortedSets_State(firstindex(twoss.m1), firstindex(twoss.m2))) m1 = twoss.m1 m2 = twoss.m2 ord = orderobject(m1) p1 = state.p1 p2 = state.p2 while p1 != pastends...
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": [ "DataStructures.jl", "src", "sorted_set.jl" ], "ground_truth": "function Base.issubset(m1::SortedSet{K,Ord}, m2::SortedSet{K,Ord}) where {K, Ord <: Ordering}\n ord = orderobject(m1)\n if ord != orderobject(m2) ||\n length(m1) < length(m2) / log2(length(m2) + 2)\n ...
648
670
DataStructures.jl
52
function Base.issubset(m1::SortedSet{K,Ord}, m2::SortedSet{K,Ord}) where {K, Ord <: Ordering} ord = orderobject(m1) if ord != orderobject(m2) || length(m1) < length(m2) / log2(length(m2) + 2) return invoke(issubset, Tuple{Any, SortedSet}, m1, m2) end p1 = firstindex(m1) p2 = firstind...
Base.issubset(m1::SortedSet{K,Ord}, m2::SortedSet{K,Ord}) where {K, Ord <: Ordering}
[ 648, 670 ]
function Base.issubset(m1::SortedSet{K,Ord}, m2::SortedSet{K,Ord}) where {K, Ord <: Ordering} ord = orderobject(m1) if ord != orderobject(m2) || length(m1) < length(m2) / log2(length(m2) + 2) return invoke(issubset, Tuple{Any, SortedSet}, m1, m2) end p1 = firstindex(m1) p2 = firstind...
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": [ "DataStructures.jl", "src", "sparse_int_set.jl" ], "ground_truth": "function Base.copy!(to::SparseIntSet, from::SparseIntSet)\n to.packed = copy(from.packed)\n #we want to keep the null pages === NULL_INT_PAGE\n resize!(to.reverse, length(from.reverse))\n for i in eachin...
30
44
DataStructures.jl
53
function Base.copy!(to::SparseIntSet, from::SparseIntSet) to.packed = copy(from.packed) #we want to keep the null pages === NULL_INT_PAGE resize!(to.reverse, length(from.reverse)) for i in eachindex(from.reverse) page = from.reverse[i] if page === NULL_INT_PAGE to.reverse[i] ...
Base.copy!(to::SparseIntSet, from::SparseIntSet)
[ 30, 44 ]
function Base.copy!(to::SparseIntSet, from::SparseIntSet) to.packed = copy(from.packed) #we want to keep the null pages === NULL_INT_PAGE resize!(to.reverse, length(from.reverse)) for i in eachindex(from.reverse) page = from.reverse[i] if page === NULL_INT_PAGE to.reverse[i] ...
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": [ "DataStructures.jl", "src", "splay_tree.jl" ], "ground_truth": "function search_node(tree::SplayTree{K}, d::K) where K\n node = tree.root\n prev = nothing\n while node != nothing && node.data != d\n prev = node\n if node.data < d\n node = node.right...
129
141
DataStructures.jl
54
function search_node(tree::SplayTree{K}, d::K) where K node = tree.root prev = nothing while node != nothing && node.data != d prev = node if node.data < d node = node.rightChild else node = node.leftChild end end return (node == nothing) ? pre...
search_node(tree::SplayTree{K}, d::K) where K
[ 129, 141 ]
function search_node(tree::SplayTree{K}, d::K) where K node = tree.root prev = nothing while node != nothing && node.data != d prev = node if node.data < d node = node.rightChild else node = node.leftChild end end return (node == nothing) ? pre...
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": [ "DataStructures.jl", "src", "splay_tree.jl" ], "ground_truth": "function Base.delete!(tree::SplayTree{K}, d::K) where K\n node = tree.root\n x = search_node(tree, d)\n (x == nothing) && return tree\n t = nothing\n s = nothing\n\n splay!(tree, x)\n\n if x.rightCh...
158
182
DataStructures.jl
55
function Base.delete!(tree::SplayTree{K}, d::K) where K node = tree.root x = search_node(tree, d) (x == nothing) && return tree t = nothing s = nothing splay!(tree, x) if x.rightChild !== nothing t = x.rightChild t.parent = nothing end s = x s.rightChild = noth...
Base.delete!(tree::SplayTree{K}, d::K) where K
[ 158, 182 ]
function Base.delete!(tree::SplayTree{K}, d::K) where K node = tree.root x = search_node(tree, d) (x == nothing) && return tree t = nothing s = nothing splay!(tree, x) if x.rightChild !== nothing t = x.rightChild t.parent = nothing end s = x s.rightChild = noth...
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": [ "DataStructures.jl", "src", "splay_tree.jl" ], "ground_truth": "function Base.push!(tree::SplayTree{K}, d0) where K\n d = convert(K, d0)\n is_present = search_node(tree, d)\n if (is_present !== nothing) && (is_present.data == d)\n return tree\n end\n # only uni...
184
215
DataStructures.jl
56
function Base.push!(tree::SplayTree{K}, d0) where K d = convert(K, d0) is_present = search_node(tree, d) if (is_present !== nothing) && (is_present.data == d) return tree end # only unique keys are inserted node = SplayTreeNode{K}(d) y = nothing x = tree.root while x !== not...
Base.push!(tree::SplayTree{K}, d0) where K
[ 184, 215 ]
function Base.push!(tree::SplayTree{K}, d0) where K d = convert(K, d0) is_present = search_node(tree, d) if (is_present !== nothing) && (is_present.data == d) return tree end # only unique keys are inserted node = SplayTreeNode{K}(d) y = nothing x = tree.root while x !== not...
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": [ "DataStructures.jl", "src", "splay_tree.jl" ], "ground_truth": "function Base.getindex(tree::SplayTree{K}, ind) where K\n @boundscheck (1 <= ind <= tree.count) || throw(KeyError(\"$ind should be in between 1 and $(tree.count)\"))\n function traverse_tree_inorder(node::Union{Sp...
217
230
DataStructures.jl
57
function Base.getindex(tree::SplayTree{K}, ind) where K @boundscheck (1 <= ind <= tree.count) || throw(KeyError("$ind should be in between 1 and $(tree.count)")) function traverse_tree_inorder(node::Union{SplayTreeNode, Nothing}) if (node != nothing) left = traverse_tree_inorder(node.leftChi...
Base.getindex(tree::SplayTree{K}, ind) where K
[ 217, 230 ]
function Base.getindex(tree::SplayTree{K}, ind) where K @boundscheck (1 <= ind <= tree.count) || throw(KeyError("$ind should be in between 1 and $(tree.count)")) function traverse_tree_inorder(node::Union{SplayTreeNode, Nothing}) if (node != nothing) left = traverse_tree_inorder(node.leftChi...
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": [ "DataStructures.jl", "src", "swiss_dict.jl" ], "ground_truth": "function ht_keyindex(h::SwissDict, key, i0, tag)\n slots = h.slots\n keys = h.keys\n sz = length(slots)\n i = i0 & (sz-1)\n _prefetchr(pointer(h.keys, i*16+1))\n _prefetchr(pointer(h.vals, i*16+1))\n ...
149
170
DataStructures.jl
58
function ht_keyindex(h::SwissDict, key, i0, tag) slots = h.slots keys = h.keys sz = length(slots) i = i0 & (sz-1) _prefetchr(pointer(h.keys, i*16+1)) _prefetchr(pointer(h.vals, i*16+1)) #Todo/discuss: _prefetchr(pointer(h.keys, i*16+9))? @inbounds while true msk = slots[i+1] ...
ht_keyindex(h::SwissDict, key, i0, tag)
[ 149, 170 ]
function ht_keyindex(h::SwissDict, key, i0, tag) slots = h.slots keys = h.keys sz = length(slots) i = i0 & (sz-1) _prefetchr(pointer(h.keys, i*16+1)) _prefetchr(pointer(h.vals, i*16+1)) #Todo/discuss: _prefetchr(pointer(h.keys, i*16+9))? @inbounds while true msk = slots[i+1] ...
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": [ "DataStructures.jl", "src", "swiss_dict.jl" ], "ground_truth": "function _iterslots(h::SwissDict, state)\n i, sl = state\n while iszero(sl)\n i += 1\n i <= length(h.slots) || return nothing\n @inbounds msk = h.slots[i]\n sl = _find_free(msk)\n ...
244
254
DataStructures.jl
59
function _iterslots(h::SwissDict, state) i, sl = state while iszero(sl) i += 1 i <= length(h.slots) || return nothing @inbounds msk = h.slots[i] sl = _find_free(msk) sl = (~sl & 0xffff) end return ((i-1)*16 + trailing_zeros(sl) + 1, (i, _blsr(sl))) end
_iterslots(h::SwissDict, state)
[ 244, 254 ]
function _iterslots(h::SwissDict, state) i, sl = state while iszero(sl) i += 1 i <= length(h.slots) || return nothing @inbounds msk = h.slots[i] sl = _find_free(msk) sl = (~sl & 0xffff) end return ((i-1)*16 + trailing_zeros(sl) + 1, (i, _blsr(sl))) 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": [ "DataStructures.jl", "src", "swiss_dict.jl" ], "ground_truth": "function rehash!(h::SwissDict{K,V}, newsz = length(h.keys)) where {K, V}\n olds = h.slots\n oldk = h.keys\n oldv = h.vals\n sz = length(oldk)\n newsz = _tablesz(newsz)\n (newsz*SWISS_DICT_LOAD_FACTOR) ...
287
346
DataStructures.jl
60
function rehash!(h::SwissDict{K,V}, newsz = length(h.keys)) where {K, V} olds = h.slots oldk = h.keys oldv = h.vals sz = length(oldk) newsz = _tablesz(newsz) (newsz*SWISS_DICT_LOAD_FACTOR) > h.count || (newsz <<= 1) h.age += 1 h.idxfloor = 1 if h.count == 0 resize!(h.slots, n...
rehash!(h::SwissDict{K,V}, newsz = length(h.keys)) where {K, V}
[ 287, 346 ]
function rehash!(h::SwissDict{K,V}, newsz = length(h.keys)) where {K, V} olds = h.slots oldk = h.keys oldv = h.vals sz = length(oldk) newsz = _tablesz(newsz) (newsz*SWISS_DICT_LOAD_FACTOR) > h.count || (newsz <<= 1) h.age += 1 h.idxfloor = 1 if h.count == 0 resize!(h.slots, n...
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": [ "DataStructures.jl", "src", "swiss_dict.jl" ], "ground_truth": "function Base.empty!(h::SwissDict{K,V}) where {K, V}\n fill!(h.slots, _expand16(0x00))\n sz = length(h.keys)\n empty!(h.keys)\n empty!(h.vals)\n resize!(h.keys, sz)\n resize!(h.vals, sz)\n h.nbfull ...
370
382
DataStructures.jl
61
function Base.empty!(h::SwissDict{K,V}) where {K, V} fill!(h.slots, _expand16(0x00)) sz = length(h.keys) empty!(h.keys) empty!(h.vals) resize!(h.keys, sz) resize!(h.vals, sz) h.nbfull = 0 h.count = 0 h.age += 1 h.idxfloor = 1 return h end
Base.empty!(h::SwissDict{K,V}) where {K, V}
[ 370, 382 ]
function Base.empty!(h::SwissDict{K,V}) where {K, V} fill!(h.slots, _expand16(0x00)) sz = length(h.keys) empty!(h.keys) empty!(h.vals) resize!(h.keys, sz) resize!(h.vals, sz) h.nbfull = 0 h.count = 0 h.age += 1 h.idxfloor = 1 return h 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": [ "DataStructures.jl", "src", "swiss_dict.jl" ], "ground_truth": "function _setindex!(h::SwissDict{K,V}, v0, key::K) where {K, V}\n v = convert(V, v0)\n index, tag = ht_keyindex2!(h, key)\n\n if index > 0\n h.age += 1\n @inbounds h.keys[index] = key\n @in...
389
402
DataStructures.jl
62
function _setindex!(h::SwissDict{K,V}, v0, key::K) where {K, V} v = convert(V, v0) index, tag = ht_keyindex2!(h, key) if index > 0 h.age += 1 @inbounds h.keys[index] = key @inbounds h.vals[index] = v else _setindex!(h, v, key, -index, tag) end return h end
_setindex!(h::SwissDict{K,V}, v0, key::K) where {K, V}
[ 389, 402 ]
function _setindex!(h::SwissDict{K,V}, v0, key::K) where {K, V} v = convert(V, v0) index, tag = ht_keyindex2!(h, key) if index > 0 h.age += 1 @inbounds h.keys[index] = key @inbounds h.vals[index] = v else _setindex!(h, v, key, -index, tag) end return h 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": [ "DataStructures.jl", "src", "swiss_dict.jl" ], "ground_truth": "function _get!(default::Callable, h::SwissDict{K,V}, key::K) where {K, V}\n index, tag = ht_keyindex2!(h, key)\n\n index > 0 && return @inbounds h.vals[index]\n\n age0 = h.age\n v = convert(V, default())\n ...
449
467
DataStructures.jl
63
function _get!(default::Callable, h::SwissDict{K,V}, key::K) where {K, V} index, tag = ht_keyindex2!(h, key) index > 0 && return @inbounds h.vals[index] age0 = h.age v = convert(V, default()) if h.age != age0 index, tag = ht_keyindex2!(h, key) end if index > 0 h.age += 1 ...
_get!(default::Callable, h::SwissDict{K,V}, key::K) where {K, V}
[ 449, 467 ]
function _get!(default::Callable, h::SwissDict{K,V}, key::K) where {K, V} index, tag = ht_keyindex2!(h, key) index > 0 && return @inbounds h.vals[index] age0 = h.age v = convert(V, default()) if h.age != age0 index, tag = ht_keyindex2!(h, key) end if index > 0 h.age += 1 ...
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": [ "DataStructures.jl", "src", "swiss_dict.jl" ], "ground_truth": "function Base.pop!(h::SwissDict)\n isempty(h) && throw(ArgumentError(\"SwissDict must be non-empty\"))\n is = _iterslots(h, h.idxfloor)\n @assert is !== nothing\n idx, s = is\n @inbounds key = h.keys[idx]...
601
611
DataStructures.jl
64
function Base.pop!(h::SwissDict) isempty(h) && throw(ArgumentError("SwissDict must be non-empty")) is = _iterslots(h, h.idxfloor) @assert is !== nothing idx, s = is @inbounds key = h.keys[idx] @inbounds val = h.vals[idx] _delete!(h, idx) h.idxfloor = idx return key => val end
Base.pop!(h::SwissDict)
[ 601, 611 ]
function Base.pop!(h::SwissDict) isempty(h) && throw(ArgumentError("SwissDict must be non-empty")) is = _iterslots(h, h.idxfloor) @assert is !== nothing idx, s = is @inbounds key = h.keys[idx] @inbounds val = h.vals[idx] _delete!(h, idx) h.idxfloor = idx return key => val 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": [ "DataStructures.jl", "src", "trie.jl" ], "ground_truth": "function Base.keys(t::Trie{K,V},\n prefix=_empty_prefix(t),\n found=Vector{typeof(prefix)}()) where {K,V}\n if t.is_key\n push!(found, prefix)\n end\n for (char,child) in t....
78
88
DataStructures.jl
65
function Base.keys(t::Trie{K,V}, prefix=_empty_prefix(t), found=Vector{typeof(prefix)}()) where {K,V} if t.is_key push!(found, prefix) end for (char,child) in t.children keys(child, _concat(prefix, char), found) end return found end
Base.keys(t::Trie{K,V}, prefix=_empty_prefix(t), found=Vector{typeof(prefix)}()) where {K,V}
[ 78, 88 ]
function Base.keys(t::Trie{K,V}, prefix=_empty_prefix(t), found=Vector{typeof(prefix)}()) where {K,V} if t.is_key push!(found, prefix) end for (char,child) in t.children keys(child, _concat(prefix, char), found) end return found 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": [ "DataStructures.jl", "src", "trie.jl" ], "ground_truth": "function find_prefixes(t::Trie, str::T) where {T}\n prefixes = T[]\n it = partial_path(t, str)\n idx = 0\n for t in it\n if t.is_key\n push!(prefixes, str[firstindex(str):idx])\n end\n ...
154
165
DataStructures.jl
66
function find_prefixes(t::Trie, str::T) where {T} prefixes = T[] it = partial_path(t, str) idx = 0 for t in it if t.is_key push!(prefixes, str[firstindex(str):idx]) end idx = nextind(str, idx) end return prefixes end
find_prefixes(t::Trie, str::T) where {T}
[ 154, 165 ]
function find_prefixes(t::Trie, str::T) where {T} prefixes = T[] it = partial_path(t, str) idx = 0 for t in it if t.is_key push!(prefixes, str[firstindex(str):idx]) end idx = nextind(str, idx) end return prefixes 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": [ "DataStructures.jl", "src", "heaps", "minmax_heap.jl" ], "ground_truth": "function is_minmax_heap(A::AbstractVector)\n\n for i in 1:length(A)\n if on_minlevel(i)\n # check that A[i] < children A[i]\n # and grandchildren A[i]\n for j ...
143
160
DataStructures.jl
67
function is_minmax_heap(A::AbstractVector) for i in 1:length(A) if on_minlevel(i) # check that A[i] < children A[i] # and grandchildren A[i] for j in children_and_grandchildren(length(A), i) A[i] ≤ A[j] || return false end else ...
is_minmax_heap(A::AbstractVector)
[ 143, 160 ]
function is_minmax_heap(A::AbstractVector) for i in 1:length(A) if on_minlevel(i) # check that A[i] < children A[i] # and grandchildren A[i] for j in children_and_grandchildren(length(A), i) A[i] ≤ A[j] || return false end else ...
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": [ "DataStructures.jl", "src", "heaps", "minmax_heap.jl" ], "ground_truth": "function popmin!(h::BinaryMinMaxHeap)\n valtree = h.valtree\n !isempty(valtree) || throw(ArgumentError(\"heap must be non-empty\"))\n @inbounds x = valtree[1]\n y = pop!(valtree)\n if !isemp...
187
197
DataStructures.jl
68
function popmin!(h::BinaryMinMaxHeap) valtree = h.valtree !isempty(valtree) || throw(ArgumentError("heap must be non-empty")) @inbounds x = valtree[1] y = pop!(valtree) if !isempty(valtree) @inbounds valtree[1] = y @inbounds _minmax_heap_trickle_down!(valtree, 1) end return x...
popmin!(h::BinaryMinMaxHeap)
[ 187, 197 ]
function popmin!(h::BinaryMinMaxHeap) valtree = h.valtree !isempty(valtree) || throw(ArgumentError("heap must be non-empty")) @inbounds x = valtree[1] y = pop!(valtree) if !isempty(valtree) @inbounds valtree[1] = y @inbounds _minmax_heap_trickle_down!(valtree, 1) end return x...
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": [ "DataStructures.jl", "src", "heaps", "minmax_heap.jl" ], "ground_truth": "function popmax!(h::BinaryMinMaxHeap)\n valtree = h.valtree\n !isempty(valtree) || throw(ArgumentError(\"heap must be non-empty\"))\n @inbounds x, i = maximum(((valtree[j], j) for j in 1:min(lengt...
214
224
DataStructures.jl
69
function popmax!(h::BinaryMinMaxHeap) valtree = h.valtree !isempty(valtree) || throw(ArgumentError("heap must be non-empty")) @inbounds x, i = maximum(((valtree[j], j) for j in 1:min(length(valtree), 3))) y = pop!(valtree) if !isempty(valtree) && i <= length(valtree) @inbounds valtree[i] = y...
popmax!(h::BinaryMinMaxHeap)
[ 214, 224 ]
function popmax!(h::BinaryMinMaxHeap) valtree = h.valtree !isempty(valtree) || throw(ArgumentError("heap must be non-empty")) @inbounds x, i = maximum(((valtree[j], j) for j in 1:min(length(valtree), 3))) y = pop!(valtree) if !isempty(valtree) && i <= length(valtree) @inbounds valtree[i] = y...
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": [ "DataStructures.jl", "src", "heaps", "mutable_binary_heap.jl" ], "ground_truth": "function _binary_heap_pop!(ord::Ordering,\n nodes::Vector{MutableBinaryHeapNode{T}}, nodemap::Vector{Int}, nd_id::Int=1) where T\n\n # extract node\n rt = nodes[nd_id]\n v = rt.value\n ...
103
130
DataStructures.jl
70
function _binary_heap_pop!(ord::Ordering, nodes::Vector{MutableBinaryHeapNode{T}}, nodemap::Vector{Int}, nd_id::Int=1) where T # extract node rt = nodes[nd_id] v = rt.value @inbounds nodemap[rt.handle] = 0 # if node-to-remove is at end, we can just pop it # the same applies to 1-element he...
_binary_heap_pop!(ord::Ordering, nodes::Vector{MutableBinaryHeapNode{T}}, nodemap::Vector{Int}, nd_id::Int=1) where T
[ 103, 130 ]
function _binary_heap_pop!(ord::Ordering, nodes::Vector{MutableBinaryHeapNode{T}}, nodemap::Vector{Int}, nd_id::Int=1) where T # extract node rt = nodes[nd_id] v = rt.value @inbounds nodemap[rt.handle] = 0 # if node-to-remove is at end, we can just pop it # the same applies to 1-element he...
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": [ "DataStructures.jl", "src", "heaps", "mutable_binary_heap.jl" ], "ground_truth": "function _make_mutable_binary_heap(ord::Ordering, ty::Type{T}, values) where T\n # make a static binary index tree from a list of values\n\n n = length(values)\n nodes = Vector{MutableBina...
132
150
DataStructures.jl
71
function _make_mutable_binary_heap(ord::Ordering, ty::Type{T}, values) where T # make a static binary index tree from a list of values n = length(values) nodes = Vector{MutableBinaryHeapNode{T}}(undef, n) nodemap = Vector{Int}(undef, n) i::Int = 0 for v in values i += 1 @inboun...
_make_mutable_binary_heap(ord::Ordering, ty::Type{T}, values) where T
[ 132, 150 ]
function _make_mutable_binary_heap(ord::Ordering, ty::Type{T}, values) where T # make a static binary index tree from a list of values n = length(values) nodes = Vector{MutableBinaryHeapNode{T}}(undef, n) nodemap = Vector{Int}(undef, n) i::Int = 0 for v in values i += 1 @inboun...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function mean(d::Censored)\n d0 = d.uncensored\n lower = d.lower\n upper = d.upper\n log_prob_lower = _logcdf_noninclusive(d0, lower)\n log_prob_upper = logccdf(d0, upper)\n log_prob_interval = log1mexp(l...
187
197
Distributions.jl
72
function mean(d::Censored) d0 = d.uncensored lower = d.lower upper = d.upper log_prob_lower = _logcdf_noninclusive(d0, lower) log_prob_upper = logccdf(d0, upper) log_prob_interval = log1mexp(logaddexp(log_prob_lower, log_prob_upper)) μ = (xexpy(lower, log_prob_lower) + xexpy(upper, log_prob_...
mean(d::Censored)
[ 187, 197 ]
function mean(d::Censored) d0 = d.uncensored lower = d.lower upper = d.upper log_prob_lower = _logcdf_noninclusive(d0, lower) log_prob_upper = logccdf(d0, upper) log_prob_interval = log1mexp(logaddexp(log_prob_lower, log_prob_upper)) μ = (xexpy(lower, log_prob_lower) + xexpy(upper, log_prob_...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function var(d::LeftCensored)\n lower = d.lower\n log_prob_lower = _logcdf_noninclusive(d.uncensored, lower)\n log_prob_interval = log1mexp(log_prob_lower)\n dtrunc = _to_truncated(d)\n μ_interval = mean(dtr...
199
209
Distributions.jl
73
function var(d::LeftCensored) lower = d.lower log_prob_lower = _logcdf_noninclusive(d.uncensored, lower) log_prob_interval = log1mexp(log_prob_lower) dtrunc = _to_truncated(d) μ_interval = mean(dtrunc) μ = xexpy(lower, log_prob_lower) + xexpy(μ_interval, log_prob_interval) v_interval = var(d...
var(d::LeftCensored)
[ 199, 209 ]
function var(d::LeftCensored) lower = d.lower log_prob_lower = _logcdf_noninclusive(d.uncensored, lower) log_prob_interval = log1mexp(log_prob_lower) dtrunc = _to_truncated(d) μ_interval = mean(dtrunc) μ = xexpy(lower, log_prob_lower) + xexpy(μ_interval, log_prob_interval) v_interval = var(d...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function var(d::RightCensored)\n upper = d.upper\n log_prob_upper = logccdf(d.uncensored, upper)\n log_prob_interval = log1mexp(log_prob_upper)\n dtrunc = _to_truncated(d)\n μ_interval = mean(dtrunc)\n μ ...
210
220
Distributions.jl
74
function var(d::RightCensored) upper = d.upper log_prob_upper = logccdf(d.uncensored, upper) log_prob_interval = log1mexp(log_prob_upper) dtrunc = _to_truncated(d) μ_interval = mean(dtrunc) μ = xexpy(upper, log_prob_upper) + xexpy(μ_interval, log_prob_interval) v_interval = var(dtrunc) + abs...
var(d::RightCensored)
[ 210, 220 ]
function var(d::RightCensored) upper = d.upper log_prob_upper = logccdf(d.uncensored, upper) log_prob_interval = log1mexp(log_prob_upper) dtrunc = _to_truncated(d) μ_interval = mean(dtrunc) μ = xexpy(upper, log_prob_upper) + xexpy(μ_interval, log_prob_interval) v_interval = var(dtrunc) + abs...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function var(d::Censored)\n d0 = d.uncensored\n lower = d.lower\n upper = d.upper\n log_prob_lower = _logcdf_noninclusive(d0, lower)\n log_prob_upper = logccdf(d0, upper)\n log_prob_interval = log1mexp(lo...
221
236
Distributions.jl
75
function var(d::Censored) d0 = d.uncensored lower = d.lower upper = d.upper log_prob_lower = _logcdf_noninclusive(d0, lower) log_prob_upper = logccdf(d0, upper) log_prob_interval = log1mexp(logaddexp(log_prob_lower, log_prob_upper)) dtrunc = _to_truncated(d) μ_interval = mean(dtrunc) ...
var(d::Censored)
[ 221, 236 ]
function var(d::Censored) d0 = d.uncensored lower = d.lower upper = d.upper log_prob_lower = _logcdf_noninclusive(d0, lower) log_prob_upper = logccdf(d0, upper) log_prob_interval = log1mexp(logaddexp(log_prob_lower, log_prob_upper)) dtrunc = _to_truncated(d) μ_interval = mean(dtrunc) ...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function entropy(d::LeftCensored)\n d0 = d.uncensored\n lower = d.lower\n log_prob_lower_inc = logcdf(d0, lower)\n if value_support(typeof(d0)) === Discrete\n logpl = logpdf(d0, lower)\n log_prob_...
245
262
Distributions.jl
76
function entropy(d::LeftCensored) d0 = d.uncensored lower = d.lower log_prob_lower_inc = logcdf(d0, lower) if value_support(typeof(d0)) === Discrete logpl = logpdf(d0, lower) log_prob_lower = logsubexp(log_prob_lower_inc, logpl) xlogx_pl = xexpx(logpl) else log_prob_l...
entropy(d::LeftCensored)
[ 245, 262 ]
function entropy(d::LeftCensored) d0 = d.uncensored lower = d.lower log_prob_lower_inc = logcdf(d0, lower) if value_support(typeof(d0)) === Discrete logpl = logpdf(d0, lower) log_prob_lower = logsubexp(log_prob_lower_inc, logpl) xlogx_pl = xexpx(logpl) else log_prob_l...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function entropy(d::RightCensored)\n d0 = d.uncensored\n upper = d.upper\n log_prob_upper = logccdf(d0, upper)\n if value_support(typeof(d0)) === Discrete\n logpu = logpdf(d0, upper)\n log_prob_up...
263
280
Distributions.jl
77
function entropy(d::RightCensored) d0 = d.uncensored upper = d.upper log_prob_upper = logccdf(d0, upper) if value_support(typeof(d0)) === Discrete logpu = logpdf(d0, upper) log_prob_upper_inc = logaddexp(log_prob_upper, logpu) xlogx_pu = xexpx(logpu) else log_prob_upp...
entropy(d::RightCensored)
[ 263, 280 ]
function entropy(d::RightCensored) d0 = d.uncensored upper = d.upper log_prob_upper = logccdf(d0, upper) if value_support(typeof(d0)) === Discrete logpu = logpdf(d0, upper) log_prob_upper_inc = logaddexp(log_prob_upper, logpu) xlogx_pu = xexpx(logpu) else log_prob_upp...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function entropy(d::Censored)\n d0 = d.uncensored\n lower = d.lower\n upper = d.upper\n log_prob_lower_inc = logcdf(d0, lower)\n log_prob_upper = logccdf(d0, upper)\n if value_support(typeof(d0)) === Disc...
281
304
Distributions.jl
78
function entropy(d::Censored) d0 = d.uncensored lower = d.lower upper = d.upper log_prob_lower_inc = logcdf(d0, lower) log_prob_upper = logccdf(d0, upper) if value_support(typeof(d0)) === Discrete logpl = logpdf(d0, lower) logpu = logpdf(d0, upper) log_prob_lower = logsub...
entropy(d::Censored)
[ 281, 304 ]
function entropy(d::Censored) d0 = d.uncensored lower = d.lower upper = d.upper log_prob_lower_inc = logcdf(d0, lower) log_prob_upper = logccdf(d0, upper) if value_support(typeof(d0)) === Discrete logpl = logpdf(d0, lower) logpu = logpdf(d0, upper) log_prob_lower = logsub...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function pdf(d::Censored, x::Real)\n d0 = d.uncensored\n lower = d.lower\n upper = d.upper\n px = float(pdf(d0, x))\n return if _in_open_interval(x, lower, upper)\n px\n elseif x == lower\n ...
309
327
Distributions.jl
79
function pdf(d::Censored, x::Real) d0 = d.uncensored lower = d.lower upper = d.upper px = float(pdf(d0, x)) return if _in_open_interval(x, lower, upper) px elseif x == lower x == upper ? one(px) : oftype(px, cdf(d0, x)) elseif x == upper if value_support(typeof(d0)) =...
pdf(d::Censored, x::Real)
[ 309, 327 ]
function pdf(d::Censored, x::Real) d0 = d.uncensored lower = d.lower upper = d.upper px = float(pdf(d0, x)) return if _in_open_interval(x, lower, upper) px elseif x == lower x == upper ? one(px) : oftype(px, cdf(d0, x)) elseif x == upper if value_support(typeof(d0)) =...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function logpdf(d::Censored, x::Real)\n d0 = d.uncensored\n lower = d.lower\n upper = d.upper\n logpx = logpdf(d0, x)\n return if _in_open_interval(x, lower, upper)\n logpx\n elseif x == lower\n ...
329
347
Distributions.jl
80
function logpdf(d::Censored, x::Real) d0 = d.uncensored lower = d.lower upper = d.upper logpx = logpdf(d0, x) return if _in_open_interval(x, lower, upper) logpx elseif x == lower x == upper ? zero(logpx) : oftype(logpx, logcdf(d0, x)) elseif x == upper if value_suppor...
logpdf(d::Censored, x::Real)
[ 329, 347 ]
function logpdf(d::Censored, x::Real) d0 = d.uncensored lower = d.lower upper = d.upper logpx = logpdf(d0, x) return if _in_open_interval(x, lower, upper) logpx elseif x == lower x == upper ? zero(logpx) : oftype(logpx, logcdf(d0, x)) elseif x == upper if value_suppor...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function loglikelihood(d::Censored, x::AbstractArray{<:Real})\n d0 = d.uncensored\n lower = d.lower\n upper = d.upper\n logpx = logpdf(d0, first(x))\n log_prob_lower = lower === nothing ? zero(logpx) : oftyp...
349
363
Distributions.jl
81
function loglikelihood(d::Censored, x::AbstractArray{<:Real}) d0 = d.uncensored lower = d.lower upper = d.upper logpx = logpdf(d0, first(x)) log_prob_lower = lower === nothing ? zero(logpx) : oftype(logpx, logcdf(d0, lower)) log_prob_upper = upper === nothing ? zero(logpx) : oftype(logpx, _logcc...
loglikelihood(d::Censored, x::AbstractArray{<:Real})
[ 349, 363 ]
function loglikelihood(d::Censored, x::AbstractArray{<:Real}) d0 = d.uncensored lower = d.lower upper = d.upper logpx = logpdf(d0, first(x)) log_prob_lower = lower === nothing ? zero(logpx) : oftype(logpx, logcdf(d0, lower)) log_prob_upper = upper === nothing ? zero(logpx) : oftype(logpx, _logcc...
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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function cdf(d::Censored, x::Real)\n lower = d.lower\n upper = d.upper\n result = cdf(d.uncensored, x)\n return if lower !== nothing && x < lower\n zero(result)\n elseif upper === nothing || x < upper...
365
376
Distributions.jl
82
function cdf(d::Censored, x::Real) lower = d.lower upper = d.upper result = cdf(d.uncensored, x) return if lower !== nothing && x < lower zero(result) elseif upper === nothing || x < upper result else one(result) end end
cdf(d::Censored, x::Real)
[ 365, 376 ]
function cdf(d::Censored, x::Real) lower = d.lower upper = d.upper result = cdf(d.uncensored, x) return if lower !== nothing && x < lower zero(result) elseif upper === nothing || x < upper result else one(result) end 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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function logcdf(d::Censored, x::Real)\n lower = d.lower\n upper = d.upper\n result = logcdf(d.uncensored, x)\n return if d.lower !== nothing && x < d.lower\n oftype(result, -Inf)\n elseif d.upper === ...
378
389
Distributions.jl
83
function logcdf(d::Censored, x::Real) lower = d.lower upper = d.upper result = logcdf(d.uncensored, x) return if d.lower !== nothing && x < d.lower oftype(result, -Inf) elseif d.upper === nothing || x < d.upper result else zero(result) end end
logcdf(d::Censored, x::Real)
[ 378, 389 ]
function logcdf(d::Censored, x::Real) lower = d.lower upper = d.upper result = logcdf(d.uncensored, x) return if d.lower !== nothing && x < d.lower oftype(result, -Inf) elseif d.upper === nothing || x < d.upper result else zero(result) end 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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function ccdf(d::Censored, x::Real)\n lower = d.lower\n upper = d.upper\n result = ccdf(d.uncensored, x)\n return if lower !== nothing && x < lower\n one(result)\n elseif upper === nothing || x < uppe...
391
402
Distributions.jl
84
function ccdf(d::Censored, x::Real) lower = d.lower upper = d.upper result = ccdf(d.uncensored, x) return if lower !== nothing && x < lower one(result) elseif upper === nothing || x < upper result else zero(result) end end
ccdf(d::Censored, x::Real)
[ 391, 402 ]
function ccdf(d::Censored, x::Real) lower = d.lower upper = d.upper result = ccdf(d.uncensored, x) return if lower !== nothing && x < lower one(result) elseif upper === nothing || x < upper result else zero(result) end 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": [ "Distributions.jl", "src", "censored.jl" ], "ground_truth": "function logccdf(d::Censored{<:Any,<:Any,T}, x::Real) where {T}\n lower = d.lower\n upper = d.upper\n result = logccdf(d.uncensored, x)\n return if lower !== nothing && x < lower\n zero(result)\n else...
404
415
Distributions.jl
85
function logccdf(d::Censored{<:Any,<:Any,T}, x::Real) where {T} lower = d.lower upper = d.upper result = logccdf(d.uncensored, x) return if lower !== nothing && x < lower zero(result) elseif upper === nothing || x < upper result else oftype(result, -Inf) end end
logccdf(d::Censored{<:Any,<:Any,T}, x::Real) where {T}
[ 404, 415 ]
function logccdf(d::Censored{<:Any,<:Any,T}, x::Real) where {T} lower = d.lower upper = d.upper result = logccdf(d.uncensored, x) return if lower !== nothing && x < lower zero(result) elseif upper === nothing || x < upper result else oftype(result, -Inf) end 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": [ "Distributions.jl", "src", "genericrand.jl" ], "ground_truth": "function _rand!(\n rng::AbstractRNG,\n s::Sampleable{ArrayLikeVariate{N}},\n x::AbstractArray{<:AbstractArray{<:Real,N}},\n allocate::Bool,\n) where {N}\n if allocate\n @inbounds for i in eachindex...
156
172
Distributions.jl
86
function _rand!( rng::AbstractRNG, s::Sampleable{ArrayLikeVariate{N}}, x::AbstractArray{<:AbstractArray{<:Real,N}}, allocate::Bool, ) where {N} if allocate @inbounds for i in eachindex(x) x[i] = rand(rng, s) end else @inbounds for xi in x rand!(rng...
_rand!( rng::AbstractRNG, s::Sampleable{ArrayLikeVariate{N}}, x::AbstractArray{<:AbstractArray{<:Real,N}}, allocate::Bool, ) where {N}
[ 156, 172 ]
function _rand!( rng::AbstractRNG, s::Sampleable{ArrayLikeVariate{N}}, x::AbstractArray{<:AbstractArray{<:Real,N}}, allocate::Bool, ) where {N} if allocate @inbounds for i in eachindex(x) x[i] = rand(rng, s) end else @inbounds for xi in x rand!(rng...
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": [ "Distributions.jl", "src", "matrixvariates.jl" ], "ground_truth": "function cov(d::MatrixDistribution)\n M = length(d)\n V = zeros(partype(d), M, M)\n iter = CartesianIndices(size(d))\n for el1 = 1:M\n for el2 = 1:el1\n i, j = Tuple(iter[el1])\n ...
54
66
Distributions.jl
87
function cov(d::MatrixDistribution) M = length(d) V = zeros(partype(d), M, M) iter = CartesianIndices(size(d)) for el1 = 1:M for el2 = 1:el1 i, j = Tuple(iter[el1]) k, l = Tuple(iter[el2]) V[el1, el2] = cov(d, i, j, k, l) end end return V + tri...
cov(d::MatrixDistribution)
[ 54, 66 ]
function cov(d::MatrixDistribution) M = length(d) V = zeros(partype(d), M, M) iter = CartesianIndices(size(d)) for el1 = 1:M for el2 = 1:el1 i, j = Tuple(iter[el1]) k, l = Tuple(iter[el2]) V[el1, el2] = cov(d, i, j, k, l) end end return V + tri...
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": [ "Distributions.jl", "src", "multivariates.jl" ], "ground_truth": "function cor(d::MultivariateDistribution)\n C = cov(d)\n n = size(C, 1)\n @assert size(C, 2) == n\n R = Matrix{eltype(C)}(undef, n, n)\n\n for j = 1:n\n for i = 1:j-1\n @inbounds R[i, ...
98
115
Distributions.jl
88
function cor(d::MultivariateDistribution) C = cov(d) n = size(C, 1) @assert size(C, 2) == n R = Matrix{eltype(C)}(undef, n, n) for j = 1:n for i = 1:j-1 @inbounds R[i, j] = R[j, i] end R[j, j] = 1.0 for i = j+1:n @inbounds R[i, j] = C[i, j] / ...
cor(d::MultivariateDistribution)
[ 98, 115 ]
function cor(d::MultivariateDistribution) C = cov(d) n = size(C, 1) @assert size(C, 2) == n R = Matrix{eltype(C)}(undef, n, n) for j = 1:n for i = 1:j-1 @inbounds R[i, j] = R[j, i] end R[j, j] = 1.0 for i = j+1:n @inbounds R[i, j] = C[i, j] / ...
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": [ "Distributions.jl", "src", "product.jl" ], "ground_truth": "function __logpdf(\n d::ProductDistribution{N,M},\n x::AbstractArray{<:Real,N},\n) where {N,M}\n # we use pairwise summation (https://github.com/JuliaLang/julia/pull/31020)\n # to compute `sum(logpdf.(d.dists, e...
177
187
Distributions.jl
89
function __logpdf( d::ProductDistribution{N,M}, x::AbstractArray{<:Real,N}, ) where {N,M} # we use pairwise summation (https://github.com/JuliaLang/julia/pull/31020) # to compute `sum(logpdf.(d.dists, eachvariate))` @inbounds broadcasted = Broadcast.broadcasted( logpdf, d.dists, eachvariate(...
__logpdf( d::ProductDistribution{N,M}, x::AbstractArray{<:Real,N}, ) where {N,M}
[ 177, 187 ]
function __logpdf( d::ProductDistribution{N,M}, x::AbstractArray{<:Real,N}, ) where {N,M} # we use pairwise summation (https://github.com/JuliaLang/julia/pull/31020) # to compute `sum(logpdf.(d.dists, eachvariate))` @inbounds broadcasted = Broadcast.broadcasted( logpdf, d.dists, eachvariate(...
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": [ "Distributions.jl", "src", "quantilealgs.jl" ], "ground_truth": "function quantile_bisect(d::ContinuousUnivariateDistribution, p::Real, lx::T, rx::T) where {T<:Real}\n rx < lx && throw(ArgumentError(\"empty bracketing interval [$lx, $rx]\"))\n\n # In some special cases, e.g. #...
3
35
Distributions.jl
90
function quantile_bisect(d::ContinuousUnivariateDistribution, p::Real, lx::T, rx::T) where {T<:Real} rx < lx && throw(ArgumentError("empty bracketing interval [$lx, $rx]")) # In some special cases, e.g. #1501, rx == lx` # If the distribution is degenerate the check below can fail, hence we skip it if r...
quantile_bisect(d::ContinuousUnivariateDistribution, p::Real, lx::T, rx::T) where {T<:Real}
[ 3, 35 ]
function quantile_bisect(d::ContinuousUnivariateDistribution, p::Real, lx::T, rx::T) where {T<:Real} rx < lx && throw(ArgumentError("empty bracketing interval [$lx, $rx]")) # In some special cases, e.g. #1501, rx == lx` # If the distribution is degenerate the check below can fail, hence we skip it if r...
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": [ "Distributions.jl", "src", "show.jl" ], "ground_truth": "function _use_multline_show(d::Distribution, pnames)\n # decide whether to use one-line or multi-line format\n #\n # Criteria: if total number of values is greater than 8, or\n # there are params that are neither n...
25
48
Distributions.jl
91
function _use_multline_show(d::Distribution, pnames) # decide whether to use one-line or multi-line format # # Criteria: if total number of values is greater than 8, or # there are params that are neither numbers, tuples, or vectors, # we use multi-line format # namevals = _NameVal[] mul...
_use_multline_show(d::Distribution, pnames)
[ 25, 48 ]
function _use_multline_show(d::Distribution, pnames) # decide whether to use one-line or multi-line format # # Criteria: if total number of values is greater than 8, or # there are params that are neither numbers, tuples, or vectors, # we use multi-line format # namevals = _NameVal[] mul...
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": [ "Distributions.jl", "src", "truncate.jl" ], "ground_truth": "function cdf(d::Truncated, x::Real)\n result = clamp((cdf(d.untruncated, x) - d.lcdf) / d.tp, 0, 1)\n # Special cases for values outside of the support to avoid e.g. NaN issues with `Binomial`\n return if d.lower ...
168
178
Distributions.jl
92
function cdf(d::Truncated, x::Real) result = clamp((cdf(d.untruncated, x) - d.lcdf) / d.tp, 0, 1) # Special cases for values outside of the support to avoid e.g. NaN issues with `Binomial` return if d.lower !== nothing && x < d.lower zero(result) elseif d.upper !== nothing && x >= d.upper ...
cdf(d::Truncated, x::Real)
[ 168, 178 ]
function cdf(d::Truncated, x::Real) result = clamp((cdf(d.untruncated, x) - d.lcdf) / d.tp, 0, 1) # Special cases for values outside of the support to avoid e.g. NaN issues with `Binomial` return if d.lower !== nothing && x < d.lower zero(result) elseif d.upper !== nothing && x >= d.upper ...
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": [ "Distributions.jl", "src", "truncate.jl" ], "ground_truth": "function ccdf(d::Truncated, x::Real)\n result = clamp((d.ucdf - cdf(d.untruncated, x)) / d.tp, 0, 1)\n # Special cases for values outside of the support to avoid e.g. NaN issues with `Binomial`\n return if d.lower...
191
201
Distributions.jl
93
function ccdf(d::Truncated, x::Real) result = clamp((d.ucdf - cdf(d.untruncated, x)) / d.tp, 0, 1) # Special cases for values outside of the support to avoid e.g. NaN issues with `Binomial` return if d.lower !== nothing && x <= d.lower one(result) elseif d.upper !== nothing && x > d.upper ...
ccdf(d::Truncated, x::Real)
[ 191, 201 ]
function ccdf(d::Truncated, x::Real) result = clamp((d.ucdf - cdf(d.untruncated, x)) / d.tp, 0, 1) # Special cases for values outside of the support to avoid e.g. NaN issues with `Binomial` return if d.lower !== nothing && x <= d.lower one(result) elseif d.upper !== nothing && x > d.upper ...
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": [ "Distributions.jl", "src", "univariates.jl" ], "ground_truth": "function _pdf_fill_outside!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange)\n vl = vfirst = first(X)\n vr = vlast = last(X)\n n = vlast - vfirst + 1\n if islowerbounded(d)\n lb = mi...
426
463
Distributions.jl
94
function _pdf_fill_outside!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange) vl = vfirst = first(X) vr = vlast = last(X) n = vlast - vfirst + 1 if islowerbounded(d) lb = minimum(d) if vl < lb vl = lb end end if isupperbounded(d) ub = ...
_pdf_fill_outside!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange)
[ 426, 463 ]
function _pdf_fill_outside!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange) vl = vfirst = first(X) vr = vlast = last(X) n = vlast - vfirst + 1 if islowerbounded(d) lb = minimum(d) if vl < lb vl = lb end end if isupperbounded(d) ub = ...
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": [ "Distributions.jl", "src", "univariates.jl" ], "ground_truth": "function _pdf!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange, rpe::RecursiveProbabilityEvaluator)\n vl,vr, vfirst, vlast = _pdf_fill_outside!(r, d, X)\n\n # fill central part: with non-zero pdf...
479
492
Distributions.jl
95
function _pdf!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange, rpe::RecursiveProbabilityEvaluator) vl,vr, vfirst, vlast = _pdf_fill_outside!(r, d, X) # fill central part: with non-zero pdf if vl <= vr fm1 = vfirst - 1 r[vl - fm1] = pv = pdf(d, vl) for v = (vl+1):v...
_pdf!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange, rpe::RecursiveProbabilityEvaluator)
[ 479, 492 ]
function _pdf!(r::AbstractArray, d::DiscreteUnivariateDistribution, X::UnitRange, rpe::RecursiveProbabilityEvaluator) vl,vr, vfirst, vlast = _pdf_fill_outside!(r, d, X) # fill central part: with non-zero pdf if vl <= vr fm1 = vfirst - 1 r[vl - fm1] = pv = pdf(d, vl) for v = (vl+1):v...
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": [ "Distributions.jl", "src", "univariates.jl" ], "ground_truth": "function cdf_int(d::DiscreteUnivariateDistribution, x::Real)\n # handle `NaN` and `±Inf` which can't be truncated to `Int`\n isfinite_x = isfinite(x)\n _x = isfinite_x ? x : zero(x)\n c = float(cdf(d, floor(...
496
510
Distributions.jl
96
function cdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(cdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) elseif x < 0...
cdf_int(d::DiscreteUnivariateDistribution, x::Real)
[ 496, 510 ]
function cdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(cdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) elseif x < 0...
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": [ "Distributions.jl", "src", "univariates.jl" ], "ground_truth": "function ccdf_int(d::DiscreteUnivariateDistribution, x::Real)\n # handle `NaN` and `±Inf` which can't be truncated to `Int`\n isfinite_x = isfinite(x)\n _x = isfinite_x ? x : zero(x)\n c = float(ccdf(d, floo...
512
526
Distributions.jl
97
function ccdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(ccdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) elseif x <...
ccdf_int(d::DiscreteUnivariateDistribution, x::Real)
[ 512, 526 ]
function ccdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(ccdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) elseif x <...
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": [ "Distributions.jl", "src", "univariates.jl" ], "ground_truth": "function logcdf_int(d::DiscreteUnivariateDistribution, x::Real)\n # handle `NaN` and `±Inf` which can't be truncated to `Int`\n isfinite_x = isfinite(x)\n _x = isfinite_x ? x : zero(x)\n c = float(logcdf(d, ...
528
542
Distributions.jl
98
function logcdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(logcdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) elseif...
logcdf_int(d::DiscreteUnivariateDistribution, x::Real)
[ 528, 542 ]
function logcdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(logcdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) elseif...
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": [ "Distributions.jl", "src", "univariates.jl" ], "ground_truth": "function logccdf_int(d::DiscreteUnivariateDistribution, x::Real)\n # handle `NaN` and `±Inf` which can't be truncated to `Int`\n isfinite_x = isfinite(x)\n _x = isfinite_x ? x : zero(x)\n c = float(logccdf(d...
544
558
Distributions.jl
99
function logccdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(logccdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) else...
logccdf_int(d::DiscreteUnivariateDistribution, x::Real)
[ 544, 558 ]
function logccdf_int(d::DiscreteUnivariateDistribution, x::Real) # handle `NaN` and `±Inf` which can't be truncated to `Int` isfinite_x = isfinite(x) _x = isfinite_x ? x : zero(x) c = float(logccdf(d, floor(Int, _x))) return if isfinite_x c elseif isnan(x) oftype(c, NaN) else...