-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
It would be nice to be able to convert a Block to a Tuple. Of course it leaves the question of whether it should convert to a tuple of Integer or Block{1}. I would vote for the latter but I could see arguments either way.
This would be analagous to:
julia> Tuple(CartesianIndex(2, 2))
(2, 2)in Base, so either:
julia> using BlockArrays
julia> Base.Tuple(b::Block) = b.n
Tuple
julia> Tuple(Block(2, 2))
(2, 2)or:
julia> Base.Tuple(b::Block) = Block.(b.n)
Tuple
julia> Tuple(Block(2, 2))
(Block(2), Block(2))There are a number of places in the source code where the definition Base.Tuple(b::Block) = Block.(b.n) would be useful, for example:
Line 152 in d113dd3
| k, j = b.n |
Line 35 in d113dd3
| to_indices(A, inds, (Block.(I[1].n)..., tail(I)...)) |
BlockArrays.jl/src/blockindices.jl
Line 44 in d113dd3
| Block{N, T}(ntuple(i -> blocks[i].n[1], Val(N))) |
BlockArrays.jl/src/pseudo_blockarray.jl
Line 240 in d113dd3
| range = getindex.(axes(block_arr), Block.(block.n)) |
It seems common to want a
Tuple of Block{1} so perhaps that could guide the design choice (also that it loses less information about the input, so is closer in spirit to a conversion).Metadata
Metadata
Assignees
Labels
No labels