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

ind2sub doc example is broken #23600

Closed
ararslan opened this issue Sep 6, 2017 · 2 comments
Closed

ind2sub doc example is broken #23600

ararslan opened this issue Sep 6, 2017 · 2 comments
Labels
arrays [a, r, r, a, y, s] docs This change adds or pertains to documentation

Comments

@ararslan
Copy link
Member

ararslan commented Sep 6, 2017

The help text:

help?> ind2sub
search: ind2sub

  ind2sub(a, index) -> subscripts

  Returns a tuple of subscripts into array a corresponding to the linear index index.

     Examples
    ≡≡≡≡≡≡≡≡≡≡

  julia> A = ones(5,6,7);

  julia> ind2sub(A,35)
  (5, 1, 2)

  julia> ind2sub(A,70)
  (5, 2, 3)

  ind2sub(dims, index) -> subscripts

  Returns a tuple of subscripts into an array with dimensions dims, corresponding to the linear index index.

     Examples
    ≡≡≡≡≡≡≡≡≡≡

  i, j, ... = ind2sub(size(A), indmax(A))
...

What happens when you run the last line in the above example:

julia> A = ones(5, 6, 7);

julia> ind2sub(size(A), indmax(A))
ERROR: MethodError: no method matching ind2sub(::Tuple{Int64,Int64,Int64}, ::CartesianIndex{3})
Closest candidates are:
  ind2sub(::AbstractArray, ::Any) at abstractarray.jl:1617
  ind2sub(::Tuple{Vararg{Integer,N}} where N, ::Integer) at abstractarray.jl:1694
  ind2sub(::Union{Tuple{Vararg{Integer,N}}, Tuple{Vararg{AbstractUnitRange,N}}}, ::AbstractArray{#s51,1} where #s51<:Integer) where N at abstractarray.jl:1750

The change happened in #22907, which changed the output of indmax from a linear index to a Cartesian index if the input is multidimensional.

@ararslan ararslan added arrays [a, r, r, a, y, s] docs This change adds or pertains to documentation labels Sep 6, 2017
@JeffBezanson
Copy link
Member

This is great --- we can remove the example, since you no longer need ind2sub in that case. Once all the examples are removed, we can remove the function :)

@mbauman
Copy link
Member

mbauman commented Sep 22, 2017

This also now fails more gracefully after #23708.

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] docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

3 participants