Skip to content

Reshape with Colon and UnitRange #222

Closed
@mcabbott

Description

@mcabbott

This fails with Base.OneTo too, issue JuliaLang/julia#39951, but the error in the offset case is different:

julia> reshape(rand(Int8, 12), 11:13, 11:14)
3×4 OffsetArray(::Array{Int8,2}, 11:13, 11:14) with eltype Int8 with indices 11:13×11:14:
 -65   38  -33  -87
 113   41  108   -9
 -19  -34  -34  -99

julia> reshape(rand(Int8, 12), 11:13, :)
ERROR: MethodError: no method matching _offset(::Base.OneTo{Int64}, ::Colon)
Closest candidates are:
  _offset(::AbstractUnitRange, ::AbstractUnitRange) at /Users/me/.julia/packages/OffsetArrays/lli7H/src/utils.jl:10
  _offset(::AbstractUnitRange, ::Integer) at /Users/me/.julia/packages/OffsetArrays/lli7H/src/utils.jl:11
Stacktrace:
 [1] map(::typeof(OffsetArrays._offset), ::Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}, ::Tuple{UnitRange{Int64},Colon}) at ./tuple.jl:177
 [2] reshape(::Array{Int8,1}, ::Tuple{UnitRange{Int64},Colon}) at /Users/me/.julia/packages/OffsetArrays/lli7H/src/OffsetArrays.jl:257
 [3] reshape(::Array{Int8,1}, ::UnitRange{Int64}, ::Colon) at /Users/me/.julia/packages/OffsetArrays/lli7H/src/OffsetArrays.jl:254
 [4] top-level scope at REPL[11]:1

(My assumption is that : should mean 1:4 here.)

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