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

reshape does not accept a Colon alongside a Base.OneTo as the new dimensions #39951

Open
jishnub opened this issue Mar 8, 2021 · 0 comments
Open
Labels
arrays [a, r, r, a, y, s]

Comments

@jishnub
Copy link
Contributor

jishnub commented Mar 8, 2021

Currently reshape accepts a combination of Base.OneTo and Ints to specify the new shape, with the possibility of specifying one dimension implicitly through a Colon. However it is not possible to couple a Colon with a Base.OneTo.

julia> r = ones(2)
2-element Vector{Float64}:
 1.0
 1.0

julia> reshape(r, Base.OneTo(2), 1)  # works
2×1 Matrix{Float64}:
 1.0
 1.0

julia> reshape(r, 2, :) # works
2×1 Matrix{Float64}:
 1.0
 1.0

julia> reshape(r, Base.OneTo(2), :) # doesn't work
ERROR: MethodError: no method matching reshape(::Vector{Float64}, ::Base.OneTo{Int64}, ::Colon)
Closest candidates are:
  reshape(::AbstractArray, ::Union{Int64, AbstractUnitRange}...) at reshapedarray.jl:110
  reshape(::AbstractArray, ::Union{Colon, Int64}...) at reshapedarray.jl:117
  reshape(::Array{T, M}, ::Tuple{Vararg{Int64, N}}) where {T, N, M} at reshapedarray.jl:40
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[8]:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

No branches or pull requests

2 participants