Finding specific methods in Julia documentation

I’m trying to find the 1.X equivalent for flipdim. The intertubes told me that it had been replaced by reverse with a dims keyword

https://github.com/JuliaLang/julia/pull/26369

Humorously i can’t figure out how it’s supposed to work through the PR. I looked in the documentation through search, and none of the reverse methods that show up are the one I think I’m looking for (incidentally the first one that shows up is for String).

So naturally i ran methods() on reverse and found,

[ 10] reverse(A::Array{T,N} where N; dims) where T in Base at arraymath.jl:62

But I’m not actually sure the dims in that method is a dims keyword, but it seems likely.

But that didn’t help me located it in the documentation, i.e. i’m searching through the array stuff by hand and not finding it, wondering if maybe it’s in the documentation for an ArrayMath package, or something, because arraymath is not Base.

Hoping someone can teach me to fish.

Thanks.

DOH.

reverse(A; dims::Integer)

Reverse A in dimension dims .

i think that’s what i was looking for… Correct ?

However, my more general question remains, if I knew that the form was

reverse(A; dims)

is there a way to find the documentation for that specific method ?

I was struggling with something similar, and was told to run Julia v0.7:
it gives deprecation warnings.
Specifically, A=[1 2; 3 4]; flipdim(A,2) yields

┌ Warning: `flipdim(A, d)` is deprecated, use `reverse(A, dims=d)` instead.

i thought about that, i guess it’s that much trouble to go install an old version.
also I need to figure out what the “.’” operator does…

Google search? Usually works for me…

1 Like

For me, web search usually does not work. You must be darn good specifying search terms! :slightly_smiling_face:

1 Like

clearly something as generic as searching on something as generic as “reverse” is going to be a problem in terms of finding a specific method.

although searching on “reverse keyword dims” did bring up the pull request.

I was thinking something more along the lines of hoogle, where i could put in something like

reverse(Array{Int,1})
or
reverse(String)

and it would match the correct method and provide documentation.

Now, that would be cool. I haven’t just volunteered to create that, have I ?? :laughing:

2 Likes

I rest my case!

It gets even better with Ecosia:

3 Likes
julia> A = rand(3, 3);

help?> reverse(A; dims=1)
  reverse(A; dims::Integer)

  Reverse A in dimension dims.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> b = [1 2; 3 4]
  2×2 Array{Int64,2}:
   1  2
   3  4
  
  julia> reverse(b, dims=2)
  2×2 Array{Int64,2}:
   2  1
   4  3

(end of output)

5 Likes

I find that using ? funcname(a) to get just the documentation for the relevant method sometimes works and sometimes does not. Is there a rhyme and reason? Or does this need a bug report? For example: ? reverse prints all doc strings for reverse, as expected. And s = "cat"; followed by ? reverse(s) does print only docs for reverse(::AbstractString), which is the desired behavior. But, contrast with the following: ? empty prints documentation for three methods. Doing d = Dict(1 => 2); followed by ? empty(d) prints documentation for two methods, those for AbstractDict and AbstractVector. If I load packages on top of those at startup then ? empty(d) prints even more methods.

I find that the example above, ? empty(d) gives the same result for versions (modulo beta versions) of Julia 1.5, 1.6, 1.7, 1.8. Searching the issues with queries such as “documentation method repl” doesn’t turn anything up.

Indeed that looks like a bug. The MWE is

Docs.doc(empty, Tuple{Dict})

and I could not find an existing issue, so it would be great if you could open one.

1 Like