Skip to content
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

mortar([Block(1)[1:2], Block(2)[1:2]])[Block(1)] has type Vector{BlockIndex{1}} instead of BlockIndexRange{1} #404

Open
mtfishman opened this issue Jun 9, 2024 · 0 comments

Comments

@mtfishman
Copy link
Collaborator

For example:

julia> using BlockArrays

julia> a = mortar([Block(1)[1:2], Block(2)[1:2]])
2-blocked 4-element BlockVector{BlockIndex{1}, Vector{BlockArrays.BlockIndexRange{1, Tuple{UnitRange{Int64}}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}:
 Block(1)[1]
 Block(1)[2]
 ───────────
 Block(2)[1]
 Block(2)[2]

julia> a[Block(1)]
2-element Vector{BlockIndex{1}}:
 Block(1)[1]
 Block(1)[2]

julia> typeof(a[Block(1)])
Vector{BlockIndex{1}} (alias for Array{BlockIndex{1}, 1})

julia> blocks(a)[1]
Block(1)[1:2]

julia> typeof(blocks(a)[1])
BlockArrays.BlockIndexRange{1, Tuple{UnitRange{Int64}}}

julia> import Pkg; Pkg.status("BlockArrays")
Status `.../Project.toml`
  [8e7c35d0] BlockArrays v1.0.1

julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

Ideally a[Block(1)] would act like blocks(a)[1] and preserve the type of the block as it was input, i.e. have the type BlockIndexRange{1}.

@mtfishman mtfishman changed the title a[Block(i...)] sometimes outputs a different type from block(a)[i...] block(a)[i...] sometimes preserves block types better than a[Block(i...)] Jun 10, 2024
@mtfishman mtfishman changed the title block(a)[i...] sometimes preserves block types better than a[Block(i...)] mortar([Block(1)[1:2], Block(2)[1:2]])[Block(1) has type Vector{BlockIndex{1}} instead of BlockIndexRange{1} Jun 10, 2024
@mtfishman mtfishman changed the title mortar([Block(1)[1:2], Block(2)[1:2]])[Block(1) has type Vector{BlockIndex{1}} instead of BlockIndexRange{1} mortar([Block(1)[1:2], Block(2)[1:2]])[Block(1)] has type Vector{BlockIndex{1}} instead of BlockIndexRange{1} Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant