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

reintepret reshape of 0-dimensional array #54623

Open
FeatherPurple opened this issue May 29, 2024 · 1 comment
Open

reintepret reshape of 0-dimensional array #54623

FeatherPurple opened this issue May 29, 2024 · 1 comment
Labels
domain:arrays [a, r, r, a, y, s] kind:bug Indicates an unexpected problem or unintended behavior

Comments

@FeatherPurple
Copy link

FeatherPurple commented May 29, 2024

I installed Julia with the command curl -fsSL https://install.julialang.org | sh. I couldn't find anyone else talking about this specific issue anywhere I looked, but I apologize if I just missed it. There seems to be a problem displaying reinterpreted/reshapeed 0-dimensional arrays. Despite the fact that the elements of this array are Int64s, they are shown as 0-dimensional arrays of Int64s with unrelated contents. The setup is shown below.

julia> versioninfo()
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 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: 10 default, 0 interactive, 5 GC (on 8 virtual cores)
Environment:
  JULIA_NUM_THREADS = 10

julia> r = reinterpret(reshape, Int, fill(1 => 2))
2-element reinterpret(reshape, Int64, ::Array{Pair{Int64, Int64}, 0}) with eltype Int64:
 fill(4538293232)
 fill(4539746992)

julia> r[1], r[2], collect(r)
(1, 2, [1, 2])

julia> typeof(r)
Base.ReinterpretArray{Int64, 1, Pair{Int64, Int64}, Array{Pair{Int64, Int64}, 0}, true}

julia> typeof(fill(4538293232))
Array{Int64, 0}

julia> eltype(r)
Int64
@FeatherPurple FeatherPurple changed the title reintepret reshape of 0-dimensional reintepret reshape of 0-dimensional array May 29, 2024
@mbauman
Copy link
Sponsor Member

mbauman commented May 29, 2024

The issue here is with the ReshapeArray's index style and accessing with more than one index:

julia> r = reinterpret(reshape, Int, fill(1 => 2))
2-element reinterpret(reshape, Int64, ::Array{Pair{Int64, Int64}, 0}) with eltype Int64:
 fill(925)
 fill(0)

julia> r[1]
1

julia> r[1,1]
0-dimensional Array{Int64, 0}:
4468297136

julia> r[1,1,1]
0-dimensional Array{Int64, 0}:
0

julia> r[1,1,1,1]
ERROR: StackOverflowError:

@mbauman mbauman added kind:bug Indicates an unexpected problem or unintended behavior domain:arrays [a, r, r, a, y, s] labels May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays [a, r, r, a, y, s] kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants