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

Use similar in empty #49958

Merged
merged 4 commits into from
Jan 14, 2024
Merged

Use similar in empty #49958

merged 4 commits into from
Jan 14, 2024

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented May 26, 2023

After this,

julia> S = StructArray{Complex{Int}}(([1,2], [3,4]))
2-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}:
 1 + 3im
 2 + 4im

julia> empty(S)
0-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}

instead of

julia> empty(S)
Complex{Int64}[]

This behavior matches the docstring now: "Create an empty vector similar to v". Often, similar will fall back to creating a Vector, so the current behavior will be preserved.

I'm unsure about what test to add for this, so suggestions are welcome. Test added for a StructArray through a new test helper

@Seelengrab
Copy link
Contributor

Seelengrab commented May 26, 2023

Perhaps a test with the OffsetArray testhelper or some other non-Vector?

base/abstractarray.jl Outdated Show resolved Hide resolved
@jishnub
Copy link
Contributor Author

jishnub commented Jan 12, 2024

Gentle bump

@N5N3
Copy link
Member

N5N3 commented Jan 12, 2024

This list is too long to go through.
@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@N5N3 N5N3 merged commit cd4f44d into JuliaLang:master Jan 14, 2024
5 of 8 checks passed
@jishnub jishnub deleted the emptysimilar branch January 14, 2024 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants