OneHotArrays.jl icon indicating copy to clipboard operation
OneHotArrays.jl copied to clipboard

Not every OneHotVector `isa OneHotVector`

Open mcabbott opened this issue 5 months ago • 0 comments

This y is a little odd. Is the problem just that show lies about its type, or that the alias OneHotVector is overly specific?

julia> x = onehotbatch(fill(2), 1:3)
3-element OneHotVector(::UInt32) with eltype Bool:
 ⋅
 1
 ⋅

julia> x isa OneHotVector  # no problem!
true

julia> dump(x)
OneHotVector{UInt32}
  indices: UInt32 0x00000002
  nlabels: Int64 3

julia> y = OneHotArray(fill(2), 3)
3-element OneHotVector(::Array{Int64, 0}) with eltype Bool:
 ⋅
 1
 ⋅

julia> y isa OneHotVector  # problem?
false

julia> dump(y)  # has mutable storage
OneHotArray{Int64, 0, 1, Array{Int64, 0}}
  indices: Array{Int64}(()) fill(2)
  nlabels: Int64 3

mcabbott avatar May 06 '25 03:05 mcabbott