Skip to content

Incorporate block-sizes into axes #91

@dlfivefifty

Description

@dlfivefifty

I've always felt the design for block sizes is not very elegant, and the termonology is completely unintuitive (even after acting as primary maintainer for this package for several years). I believe a better design would move this to be part of the axes of an array. That is, we would have the following behaviour:

bs = [1,5,3] # block sizes
n = sum(bs) # total length of vector
x = BlockVector(randn(n), bs) # returns a Block vector with block-sizes [1,5,3]
a = axes(x,1) 
a === BlockSlice(Base.OneTo(n), bs) # BlockSlice plays same role as `Slice`
length(a[Block(2)]) === 5 # returns the size of the second block
a[Block(2)][3] === 4 # returns the "global" index into `x` of the 3rd entry of the second block. 
# This replaces blockindex2global:
x[a[Block(2)][3]] === x[4]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions