Skip to content

Commit f7a6caa

Browse files
committed
move the 1 down instead
1 parent 036f700 commit f7a6caa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/array.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ function Base.copyto!(dst::Array{T,N}, src::OneHotArray{<:Any,<:Any,N,<:AnyGPUAr
9292
if Bool(v)
9393
@inbounds x.indices[I...] = i
9494
elseif x.indices[I...] == i
95-
@inbounds x.indices[I...] = 0
95+
# writing 0, at position of the 1 => move the 1 down if possible
96+
i == x.nlabels && throw(ArgumentError("`setindex!` here would leave the `OneHotArray` without a hot one (in this column)"))
97+
@inbounds x.indices[I...] = i+1
98+
else
99+
# writing 0, where it's already 0 => do nothing
96100
end
97101
x
98102
end

0 commit comments

Comments
 (0)