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

h[v]cat nonsense with julia arrays

Open thofma opened this issue 3 years ago • 4 comments

I am not sure if we want to support h[v]cat with julia arrays, but at the moment it gives garbage:

julia> vcat(ZZ[5 6; 5 2], [1 2])
2×2 Matrix{Any}:
  [5 6; 5 2]   [5 6; 5 2]
 1            2

julia> vcat(ZZ[5 6; 5 2], [1 2; 3 4])
3×2 Matrix{Any}:
  [5 6; 5 2]   [5 6; 5 2]
 1            2
 3            4

thofma avatar Feb 09 '22 12:02 thofma

Ergh! I guess it shouldn't do that, even if we didn't want to support it.

wbhart avatar Feb 09 '22 13:02 wbhart

Oh I see, this is a Julia function doing this, because they don't type their inputs to Matrix. So it accepts our matrix type which is close enough to the Julia interface that this actually succeeds, with a Matrix{Any}.

How do you propose to deal with it? Just a function that accepts one of our matrices and one of theirs and raises an exception?

wbhart avatar Feb 11 '22 13:02 wbhart

I don't know yet. The problem is that julia treats our matrices like anything else:

julia> vcat("x", [1 2])
2×2 Matrix{Any}:
  "x"   "x"
 1     2

julia> vcat("x", [1 2; 3 4])
3×2 Matrix{Any}:
  "x"   "x"
 1     2
 3     4

thofma avatar Feb 11 '22 14:02 thofma

Yeah, understandable, but inevitably yuck.

wbhart avatar Feb 11 '22 14:02 wbhart