Skip to content

repeat array not working with length(counts) more than array's dimensions #29614

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

Closed
johnnychen94 opened this issue Oct 12, 2018 · 2 comments
Closed
Labels
feature Indicates new feature / enhancement requests

Comments

@johnnychen94
Copy link
Member

johnnychen94 commented Oct 12, 2018

For simplicity, I remove part of results

For 1-d Vector, this works

julia> a = ones(2)
2-element Array{Float64,1}:

julia> repeat(a,1,2,3)
2×2×3 Array{Float64,3}:

For Array more than 1-d, this doesn't

julia> a = ones(2,2)
2×2 Array{Float64,2}:

julia> repeat(a,1,2,3) # I think this should work
ERROR: BoundsError: attempt to access 2×4×3 Array{Float64,3} at index [Base.OneTo(2), Base.OneTo(2)]

But this does,

julia> a = ones(2,2)
2×2 Array{Float64,2}:

julia> repeat(a,1,1,1)
2×2×1 Array{Float64,3}:

A temporary solution to repeat in higher dimension is to reshape first

julia> a = ones(2,2)
2×2 Array{Float64,2}:

julia> repeat(repeat(a,1,1,1),1,2,3)
2×4×3 Array{Float64,3}:

Platform Info:
OS: Linux (x86_64-redhat-linux)
CPU: Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)


@nalimilan
Copy link
Member

I'd say this qualifies as a feature request. The fact that non-existent dimensions are accepted for vectors isn't documented AFAICT.

@nalimilan nalimilan added the feature Indicates new feature / enhancement requests label Oct 12, 2018
@johnnychen94
Copy link
Member Author

fixed by #29626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests
Projects
None yet
Development

No branches or pull requests

2 participants