You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closes#471.
This removes constructors `BlockRange()`, `BlockRange(2, 2)`, and
`BlockRange(1:2, 1:2)`. Instead, the more explicit versions
`BlockRange(())`, `BlockRange((2, 2))`, and `BlockRange((1:2, 1:2))` can
be used.
This now makes `BlockRange` constructors more consistent with
`CartesianIndices` constructors:
```julia
julia> CartesianIndices()
ERROR: MethodError: no method matching CartesianIndices()
The type `CartesianIndices` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
CartesianIndices(::Tuple{})
@ Base multidimensional.jl:271
CartesianIndices(::AbstractArray)
@ Base multidimensional.jl:281
CartesianIndices(::R) where {N, R<:NTuple{N, OrdinalRange{Int64, Int64}}}
@ Base multidimensional.jl:268
...
Stacktrace:
[1] top-level scope
@ REPL[9]:1
[2] top-level scope
@ none:1
julia> CartesianIndices(2, 2)
ERROR: MethodError: no method matching CartesianIndices(::Int64, ::Int64)
The type `CartesianIndices` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
CartesianIndices(::Tuple{})
@ Base multidimensional.jl:271
CartesianIndices(::AbstractArray)
@ Base multidimensional.jl:281
CartesianIndices(::R) where {N, R<:NTuple{N, OrdinalRange{Int64, Int64}}}
@ Base multidimensional.jl:268
...
Stacktrace:
[1] top-level scope
@ REPL[12]:1
[2] top-level scope
@ none:1
julia> CartesianIndices(1:2, 1:2)
ERROR: MethodError: no method matching CartesianIndices(::UnitRange{Int64}, ::UnitRange{Int64})
The type `CartesianIndices` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
CartesianIndices(::AbstractArray)
@ Base multidimensional.jl:281
CartesianIndices(::Tuple{})
@ Base multidimensional.jl:271
CartesianIndices(::R) where {N, R<:NTuple{N, OrdinalRange{Int64, Int64}}}
@ Base multidimensional.jl:268
...
Stacktrace:
[1] top-level scope
@ REPL[13]:1
[2] top-level scope
@ none:1
julia> CartesianIndices(())
CartesianIndices(())
julia> CartesianIndices((2, 2))
CartesianIndices((2, 2))
julia> CartesianIndices((1:2, 1:2))
CartesianIndices((1:2, 1:2))
```
and removes the inconsistency pointed out in #471 when calling
`BlockRange(::AbstractUnitRange)` vs. `BlockRange(::AbstractVector)`:
```julia
julia> using BlockArrays
julia> collect(BlockRange(blockedrange([2, 3])))
5-element Vector{Block{1, Int64}}:
Block(1)
Block(2)
Block(3)
Block(4)
Block(5)
julia> collect(BlockRange(mortar([1:2, 3:5])))
2-element Vector{Block{1, Int64}}:
Block(1)
Block(2)
```
This is technically breaking, though I would argue that it is a bug fix
because of the inconsistency of the current code design (i.e. I would
argue that the previous behavior of `BlockRange(::AbstractUnitRange)`
was incorrect, and therefore was a bug). I'm curious to see if this
leads to any downstream failures.
---------
Co-authored-by: Sheehan Olver <[email protected]>
3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{BlockedOneTo{Int64, ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(BlockRange(1:2),1:1:3)) with eltype Float64 with indices BlockedOneTo([1, 3]):
154
+
3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{BlockedOneTo{Int64, ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(BlockRange((1:2,)),1:1:3)) with eltype Float64 with indices BlockedOneTo([1, 3]):
0 commit comments