-
Notifications
You must be signed in to change notification settings - Fork 15
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
generalize groupby and mapmany types #54
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little unsure about this.
Many types of arrays exist that support similar
but not push!
or append!
. The similar
interface guarantees that setindex!
works (otherwise it would be useless) and base uses emptymutable
to create arrays that can be resized (again, because otherwise it would be useless; note occassionally you do want to use empty
in a "purely functional" style but never similar
)
Is there some problem we are trying to solve with similar
? Is it that some array types in the wild don't support emptymutable
when they should?
Are there actually types that return non-pushable arrays from julia> similar(1:5, 1)
1-element Vector{Int64}:
0
julia> similar(SVector(1, 2), 1)
1-element Vector{Int64}:
4
An example is shown in tests: with this PR, group and mapmany on StructArrays return StructArrays. Before, the result was a plain Vector.
emptymutable doesn't seem documented at all, and barely any package define methods for it (according to juliahub). So, emptymutable returns a plain Vector for basically all array types. |
There's mitigating facts for those. Ranges don't support
See JuliaArrays/StructArrays.jl#238
I think this is a fair observation from the outside but I can't see that this was the intention. I raised JuliaLang/julia#46230 - perhaps we can look at improving the situation. |
Still, are there any actual types whose
Do you think something like |
Off the top of my head, DistributedArrays.jl
Yeah I agree with all of that. I'd like to evolve these. I took a stab at this problem in Dictionaries.jl - look for |
Use
similar()
to create proper array types instead of plainVector
s.Also, a (minor?) fix to group().