Skip to content

Commit

Permalink
Simplify definition, test more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan committed Apr 9, 2020
1 parent a113667 commit b50fb4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/array.jl
Expand Up @@ -383,12 +383,8 @@ end
@inbounds A.refs[I...] = get!(A.pool, v)
end

function Base.fill(v::CategoricalValue{T, R}, dims::NTuple{N, Integer}) where {T, R, N}
A = CategoricalArray{T, N, R}(undef, dims)
merge_pools!(A, v, updaterefs=false)
fill!(A.refs, get!(A.pool, v))
A
end
Base.fill(v::CategoricalValue{T}, dims::NTuple{N, Integer}) where {T, N} =
CategoricalArray{T, N}(fill(level(v), dims), copy(pool(v)))

# to avoid ambiguity
Base.fill(v::CategoricalValue, dims::Tuple{}) =
Expand Down
2 changes: 1 addition & 1 deletion test/13_arraycommon.jl
Expand Up @@ -1643,7 +1643,7 @@ end
end

@testset "fill()" begin
for ordered in (false, true), dims in ([1], [2, 3], [(2, 3)], [])
for ordered in (false, true), dims in ([1], [(1,)], [2, 3], [(2, 3)], [], [()])
x = CategoricalArray{String, 1, UInt8}(["a", "b", "c"],
ordered=ordered)

Expand Down

0 comments on commit b50fb4a

Please sign in to comment.