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

Allow stack on empty collection #55735

Open
jariji opened this issue Sep 11, 2024 · 1 comment
Open

Allow stack on empty collection #55735

jariji opened this issue Sep 11, 2024 · 1 comment
Labels
domain:arrays [a, r, r, a, y, s] domain:collections Data structures holding multiple items, e.g. sets

Comments

@jariji
Copy link
Contributor

jariji commented Sep 11, 2024

julia> stack(Vector{Int}[[], [], []]; dims=1)
3×0 Matrix{Int64}

julia> stack(Vector{Int}[[], []]; dims=1)
2×0 Matrix{Int64}

julia> stack(Vector{Int}[[]]; dims=1)
1×0 Matrix{Int64}

julia> stack(Vector{Int}[]; dims=1)
ERROR: LoadError: ArgumentError: `stack` on an empty collection is not allowed

Following the pattern it seems like that last one can be a 0x0 Matrix{Int64}. Supporting the empty case can be helpful for generic programming.

cc @mcabbott @LilithHafner for stack-related work.

@mcabbott
Copy link
Contributor

This was removed from #43334 because it introduced type-instabilities. (Done here, scroll up or see discussion starting here.)

At the time I thought that some more methods of similar could make this work, but haven't made a PR.

@nsajko nsajko added domain:collections Data structures holding multiple items, e.g. sets domain:arrays [a, r, r, a, y, s] labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays [a, r, r, a, y, s] domain:collections Data structures holding multiple items, e.g. sets
Projects
None yet
Development

No branches or pull requests

3 participants