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

Writing multidimensional views is broken on v1.5 #36753

Closed
jipolanco opened this issue Jul 21, 2020 · 0 comments
Closed

Writing multidimensional views is broken on v1.5 #36753

jipolanco opened this issue Jul 21, 2020 · 0 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@jipolanco
Copy link
Contributor

jipolanco commented Jul 21, 2020

It seems like #36405, included in Julia 1.5-rc1, broke write for multidimensional SubArrays:

julia> x = rand(10, 10);

julia> v = @view x[1:3, 1:3];

julia> write(stdout, v)
ERROR: MethodError: no method matching pointer(::SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::Tuple{Int64,Int64})
Closest candidates are:
  pointer(::AbstractArray{T,N} where N) where T at abstractarray.jl:1002
  pointer(::AbstractArray{T,N} where N, ::Integer) where T at abstractarray.jl:1003
Stacktrace:
 [1] write(::Base.TTY, ::SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}) at ./io.jl:666
 [2] top-level scope at REPL[25]:1

This works as expected on Julia 1.4.2.

The problem is in the write function for SubArray, which calls pointer(::SubArray, ::Tuple{Vararg{Int}}) with a tuple of indices. This variant of pointer was removed in #36405.


Version info:

Julia Version 1.5.0-rc1.0
Commit 24f033c951* (2020-06-26 20:13 UTC)
Platform Info:
  OS: Linux (x86_64-redhat-linux)
  CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_HDF5_LIBRARY_PATH = /usr/lib64/mpich/lib
  JULIA_PKG_SERVER = pkg.julialang.org
@mbauman mbauman added the bug Indicates an unexpected problem or unintended behavior label Jul 21, 2020
@mbauman mbauman added this to the 1.5 milestone Jul 21, 2020
@mbauman mbauman self-assigned this Jul 21, 2020
mbauman added a commit that referenced this issue Jul 21, 2020
Followup to #36739 (and currently built atop it), this restores the `pointer(::SubArray{<:Any,<:Any,<:Array,<:Tuple{Vararg{RangeIndex}}}, ::Tuple)` method that was removed in #36405. It does so, however, as a deprecated method, with the actual method being implemented on `(::SubArray{...}, ::CartesianIndex)`.

The rationale here is because the `::Tuple` method was undocumented and only supported on that one _highly_ specific `SubArray` type. I am keeping this patch as minimal as possible for backporting; in the future I aim to support `Vararg{CartesianIndex, Integer}` locations to make this more `getindex`-y and move farther away from the conflation with memory offsets.
JeffBezanson pushed a commit that referenced this issue Jul 22, 2020
Followup to #36739 (and currently built atop it), this restores the `pointer(::SubArray{<:Any,<:Any,<:Array,<:Tuple{Vararg{RangeIndex}}}, ::Tuple)` method that was removed in #36405. It does so, however, as a deprecated method, with the actual method being implemented on `(::SubArray{...}, ::CartesianIndex)`.

The rationale here is because the `::Tuple` method was undocumented and only supported on that one _highly_ specific `SubArray` type. I am keeping this patch as minimal as possible for backporting; in the future I aim to support `Vararg{CartesianIndex, Integer}` locations to make this more `getindex`-y and move farther away from the conflation with memory offsets.
JeffBezanson pushed a commit that referenced this issue Jul 23, 2020
Followup to #36739 (and currently built atop it), this restores the `pointer(::SubArray{<:Any,<:Any,<:Array,<:Tuple{Vararg{RangeIndex}}}, ::Tuple)` method that was removed in #36405. It does so, however, as a deprecated method, with the actual method being implemented on `(::SubArray{...}, ::CartesianIndex)`.

The rationale here is because the `::Tuple` method was undocumented and only supported on that one _highly_ specific `SubArray` type. I am keeping this patch as minimal as possible for backporting; in the future I aim to support `Vararg{CartesianIndex, Integer}` locations to make this more `getindex`-y and move farther away from the conflation with memory offsets.

(cherry picked from commit d9b7d7e)
simeonschaub pushed a commit to simeonschaub/julia that referenced this issue Aug 11, 2020
…rt (JuliaLang#36757)

Followup to JuliaLang#36739 (and currently built atop it), this restores the `pointer(::SubArray{<:Any,<:Any,<:Array,<:Tuple{Vararg{RangeIndex}}}, ::Tuple)` method that was removed in JuliaLang#36405. It does so, however, as a deprecated method, with the actual method being implemented on `(::SubArray{...}, ::CartesianIndex)`.

The rationale here is because the `::Tuple` method was undocumented and only supported on that one _highly_ specific `SubArray` type. I am keeping this patch as minimal as possible for backporting; in the future I aim to support `Vararg{CartesianIndex, Integer}` locations to make this more `getindex`-y and move farther away from the conflation with memory offsets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants