Outdated example for Plots' "surface" command

When I type “?surface” into the REPL, I get the following:

...
 Example
  ≡≡≡≡≡≡≡≡≡
julia> x = y = range(-3, 3, length = 100)
julia> surface(x, y, (x, y) -> sinc(norm([x, y])))

This example generates the following error:
“UndefVarError: norm not defined”

Changing it to hypot does not help, because of some other error. The example is obviously outdated.

Is there someone who could easily fix this? It really does a lot to the feeling about the possibilities of getting help in Julia when the example does not work.

A working replacement is :

julia> x = y = range(-3, 3, length = 100)
julia> surface(x, y, (x, y) -> sin(x)*sin(y))
1 Like

You may not realize this, but asking that something, especially a trivial doc issue, is fixed “asap” in a free software project just strikes the wrong tone.

In this particular case, the best fix may be just adding using LinearAlgebra, which has norm. To get this fixed “asap”, the best course would be to do it yourself (in the form of a pull request)

Had you actually looked in the docs for norm, you would have found it immediately.

3 Likes

That worked well! Thanks. When I tried changing norm into something that was defined (like hypot, which I though would do something similar) and it still did not work, I figured something bigger was wrong. My bad.

The reason for asking the fix to be asap is because it figured it would just be editing the right text file, which is a small enough thing to do to just do. I have never used github other that reading what is on there, never made a pull request, and have no idea on how I would change the help documentation. I am also new to the language and eager to make adoption easy, and I know of classmates (who I want to introduce to Julia as opposed to c++, python or MatLab) to whom that error would feel like running into a small brick wall.

You are of course right, and the asap-part of my request will be striken. I still feel that my point about how it feels to new users, and how (seemingly) easy it would be to fix, makes it a fair request (without the time-demanding part).

In this particular case you can just click through buttons on Github to edit the docstring on a web interface and make a pull request that way.

I am not sure if you are joking here. For someone used to wading through compiler error messages from C++ or parsing Matlab docs with 17 different argument conventions for the same function, figuring out what norm is an how to find it should be trivially easy.

FWIW, I tried “julia norm” in various search engines and the first result was the right page.

1 Like

Yhea I know it is far from a tall order generally in programming, but we are only 7 months into a physics-bachelor so programming is really new to most. And when starting something like a new language, small problems can feel enourmus when you have not seen them before.

I’ll try and make that pull request myself, thanks for the high quality answers.

So I tried to figure out how to make the pull-request myself. It seems I have to download the file for the package from GitHub, make the change I want, and re-upload. Is that right? I tried locating the docs-file, but I can’t find it. Also I am not sure if the example should be updated, or a note about adding LinearAlgebra should be added. Feeling pretty lost, as I am wildly incompetent in this world as you may have noticed. If you find the time and will, feel free to make the necessary change. If not then I don’t know the right channel to notify whoever should know. Any point in the right direction is appriciated.

No, you should fork on Github, pkg> dev the forked URL, branch, commit, push, then submit a PR. This has been discussed in a few topics on this forum, eg

1 Like

FYI I have made the PR here: Add LinearAlgebra to make example with `norm` work by nilshg · Pull Request #2504 · JuliaPlots/Plots.jl · GitHub

@TheLateKronos in this case as Tamas said it was enough to use the GitHub web interface - click Fork on the Plots repo (top right corner), then navigate to the file in question in your forked repo (here shorthands.jl), click the little edit pen symbol on the top of your file, make the change you want, save it, then press Pull request on the overview page of your forked repo and you’re done.

1 Like

Thanks for your patience. I will definitely do this myself next time I want to commit anything.

Looks perfect, thanks a lot. Tried navigating through and it all seemed okay to do myself next time. One question though - how did you locate the help-tip for “surface” in “shorthands”? I had no idea where to look for the file, and got lost quickly myself.

Top left corner, the search box - if you type something into it, the default search will search in that repo only. So simply searching for sinc(norm([x, y])) was enough

2 Likes

Ofc, searching for something you know to be in the location you are looking for. Nice, thanks!

I did a thing! I have tried to follow your advice, and it has gotten me to this:
https://github.com/JuliaControl/ControlSystems.jl/pull/316
I know that it should probably have been done in a single commit, but I only spotted the last 2 occurances after making the first one. If this all looks good, then thanks a lot for your help, I could not have done it alone :smiley:

3 Likes

Don’t worry about that, that’s what git squash is for.

Uuuh, fancy. Cool stuff. I really love the open source spirit, and I am so happy to contribute :smiley: