Git Product home page Git Product logo

Comments (6)

dlfivefifty avatar dlfivefifty commented on June 16, 2024 1

Note blocklengths is allocating (at the moment), so if you only need the length of the K-th block you can do

julia> K = 2; length(axes(X,2)[Block(K)])
1

from blockarrays.jl.

willtebbutt avatar willtebbutt commented on June 16, 2024 1

Fantastic, thanks for the quick response.

Perhaps we should better document this?

Please -- it wasn't clear to me that axes gives you the thing to which you can apply blocklengths. The docstring is currently

help?> blocklengths
search: blocklengths blocklength

  blocklengths(a::AbstractUnitRange{Int})

  returns the length of each block of a.

A doctest (or simply a doctest-like docstring) providing example usage in the context of a BlockArray would be very helpful here :)

edit: In particular, I don't believe that axes is documented as prominently as it could be in the docs.

from blockarrays.jl.

dlfivefifty avatar dlfivefifty commented on June 16, 2024

It's blocklengths:

julia> using BlockArrays

julia> X = BlockArray(rand(4, 4), [2,2], [1,1,2])
2×3-blocked 4×4 BlockArray{Float64,2}:
 0.1272120.4295350.803334   0.864513
 0.7709430.3073990.329785   0.373277
 ──────────┼────────────┼─────────────────────
 0.9078160.903840.734343   0.73693 
 0.377840.7134810.0596666  0.6767  

julia> blocklengths(axes(X,1))
2-element Array{Int64,1}:
 2
 2

julia> blocklengths(axes(X,2))
3-element Array{Int64,1}:
 1
 1
 2

Perhaps we should better document this?

from blockarrays.jl.

dlfivefifty avatar dlfivefifty commented on June 16, 2024

I'm quite swamped with exams and childcare at the moment so a PR on this (and the other issue) would be very appreciated!

from blockarrays.jl.

willtebbutt avatar willtebbutt commented on June 16, 2024

I'm also somewhat swamped at the minute I'm afraid. Will add this to my list of things to do once I've got a bit more bandwidth.

from blockarrays.jl.

dlfivefifty avatar dlfivefifty commented on June 16, 2024

This exists now thanks to @putianyi889:

julia> X = BlockArray(rand(4, 4), [2,2], [1,1,2])
2×3-blocked 4×4 BlockArray{Float64,2}:
 0.7118420.3766590.211663  0.884155
 0.2389940.845580.622881  0.770471
 ──────────┼────────────┼────────────────────
 0.2465920.6513180.751195  0.981173
 0.2978940.2007010.396812  0.815768

julia> blocksizes(X)
([2, 2], [1, 1, 2])

from blockarrays.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.