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

`ProjectTo` is too permissive?

Open mzgubic opened this issue 3 years ago • 3 comments

Maybe this should be an error?

julia> using AxisKeys

julia> ka = wrapdims(rand(3, 2), obs=1:3, point=["a", "b"]);

julia> kb = wrapdims(rand(3, 2), obs=1:3, point=["c", "d"]);

julia> ProjectTo(ka)(kb)
2-dimensional KeyedArray(NamedDimsArray(...)) with keys:
↓   obs ∈ 3-element UnitRange{Int64}
→   point ∈ 2-element Vector{String}
And data, 3×2 Matrix{Float64}:
      ("a")      ("b")
 (1)   0.928905   0.705413
 (2)   0.493408   0.997449
 (3)   0.877819   0.816695

We probably want to think about similar things as in https://github.com/invenia/NamedDims.jl/pull/201#issuecomment-1201180921

mzgubic avatar Aug 01 '22 15:08 mzgubic

Could be. Unlike NamedDims there's some cost here to checking the key-vectors each time.

I'm not wholly convinced that this thing ought to exist. We could just accept a plain array as the gradient of a fancy one.

mcabbott avatar Aug 01 '22 15:08 mcabbott

Yeah, fair, checking the keys is a performance/correctness checking tradeoff. Maybe we could still check dimnames by deferring to NamedDims though?

mzgubic avatar Aug 01 '22 15:08 mzgubic

Yes. I guess the style of this package would be to un-wrap & call the projector for the underlying NamedDimsArray?

mcabbott avatar Aug 01 '22 15:08 mcabbott