-
Notifications
You must be signed in to change notification settings - Fork 14
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
Safe, lazy unwrapping #65
Comments
I wonder if a better way to do this might be entirely seperate to NamedDims.jl For example making this transform to remove a rundant permutation that is mixed in with views.
Then one would largely just do: Further more if simplifying arrays it is written to be extensible NamedDIms.jl |
yes AFAICT this is orthogonal to NamedDims (but a cool idea, and one that NamedDims should play nice with, if/when it exists) |
|
One more NamedDims-like issue is whether there ought to be a way of normalising so that the parent is an Array, not a lazy wrapper.
Should there be a function Or should we regard things like this as bugs to be solved upstream:
Edit: JuliaLang/julia#33029 is the issue; and here is a go at the normalising function suggested. |
Maybe we got off track here. While better stacking of views would be nice, my point here is something different. I'd like this to work: m = NamedDimsArray(rand(2,3), (:i, :j))
tm = rand()<0.5 ? m : copy(transpose(m))
unname(tm, (:i, :j)) # un-named array, always 2 x 3, sometimes ::Transpose That is, given something with the right names, but in unknown order, I want to produce an More broadly I guess I'd like ways to deal with indices only by name. This package allows some things in this direction (like |
I certainly see the appeal of this!
But i wonder what functions you have in mind here? Do you have a specifc example? I'm wondering if these functions could just be extended to handle names? |
For posterity, here's the current situation (where julia> m = NamedDimsArray(rand(2, 3), (:i, :j))
2×3 NamedDimsArray{(:i, :j),Float64,2,Array{Float64,2}}:
0.596994 0.0550656 0.204249
0.211499 0.734237 0.364742
julia> tm = transpose(m)
3×2 NamedDimsArray{(:j, :i),Float64,2,LinearAlgebra.Transpose{Float64,Array{Float64,2}}}:
0.596994 0.211499
0.0550656 0.734237
0.204249 0.364742
julia> unname(tm)
3×2 LinearAlgebra.Transpose{Float64,Array{Float64,2}}:
0.596994 0.211499
0.0550656 0.734237
0.204249 0.364742
julia> tm = copy(transpose(m))
3×2 NamedDimsArray{(:j, :i),Float64,2,Array{Float64,2}}:
0.596994 0.211499
0.0550656 0.734237
0.204249 0.364742
julia> unname(tm)
3×2 Array{Float64,2}:
0.596994 0.211499
0.0550656 0.734237
0.204249 0.364742 |
For instance Which is correct, for the rule that code not mentioning names is supposed to treat named and un-named arrays alike (apart from passing along, and checking for clashes). You could imagine other behaviours for If I need to call someone else's |
is this not julia> nda = NamedDimsArray{(:w, :x, :y, :z)}(ones(10, 20, 30, 40));
julia> pnda = permutedims(nda, (:x, :y, :z, :w));
julia> typeof(pnda)
NamedDimsArray{(:x, :y, :z, :w),Float64,4,Array{Float64,4}}
julia> size(pnda)
(20, 30, 40, 10)
julia> typeof(unname(pnda))
Array{Float64,4} |
It's close, but |
with apologies for going round in a circle here... how it this In this case don't we just want
|
This is my point 2 -- unfortunately quite a few operations on It could be spelled something like Edit: Sometimes |
Was this closed on purpose? |
It would be nice to have an unwrapping function which is guaranteed to leave the dimensions in the specified order. This would be like
parent(permutedims(A, (:i, :j))
but I think it should:Transpose
orPermutedDimsArray
if this is necessaryMy proposal was to call this
unname(A, (:i, :j))
. Then 2 can't strictly be type-stable but perhaps some wizardry can be done to make it work well.The text was updated successfully, but these errors were encountered: