Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dims keyword constructor gives unintuitive result when types do not match #200

Open
piever opened this issue Aug 26, 2021 · 2 comments
Open

Comments

@piever
Copy link
Collaborator

piever commented Aug 26, 2021

MWE:

julia> using StructArrays

julia> v = [1 3; 2 -1]
2×2 Matrix{Int64}:
 1   3
 2  -1

julia> StructArray{ComplexF64}(v, dims=1)
0-element StructArray(StructArray(), StructArray()) with eltype ComplexF64 with indices 1:0

It is probably best to error if types do not match.

@timholy
Copy link
Member

timholy commented May 11, 2022

Here's another concerning case:

julia> a = collect(reshape(1:9, 3, 3))
3×3 Matrix{Int64}:
 1  4  7
 2  5  8
 3  6  9

julia> soa = StructArray{Complex{Int}}(a; dims=1)
3-element StructArray(view(::Matrix{Int64}, 1, :), view(::Matrix{Int64}, 2, :)) with eltype Complex{Int64}:
 1 + 2im
 4 + 5im
 7 + 8im

I would have expected an error rather than just silently dropping the extra rows of a.

@piever
Copy link
Collaborator Author

piever commented May 12, 2022

CC: @simonbyrne, who I think wrote the implementation of the dims method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants