Efficient way to find which package defines an unknown type

I installed a bunch of packages from https://juliaimages.org/ and I’m going through examples, which inevitably require more packages. Say, I’m confronted with:

julia> j = rand(Gray{N0f8}, 3, 4)
ERROR: UndefVarError: N0f8 not defined

Is there a better way to hunt for the package defining N0f8 than my hunch to look for Image* or Color*?

Julia package repositories are much more organized than some other languages. Is there a tool to lookup the type name across all (most) packages known to Julia package manager?

You can do code and docs searches across all packages on https://juliahub.com/

3 Likes

Nice, but Code Search for N0f8 filtered by definition returns: No results found. Other searches are helpful, though. Very useful resource, thank you.

If you do a code search with no filtering it gives you useful results: https://juliahub.com/ui/CodeSearch?q=N0f8&u=all&t=all

3 Likes

That one is a bit tricky to find. Had to follow some comments from to figure out its origin, but seems to be defined in this location in FixedPointNumbers :

2 Likes

I can see why a text search engine would have a problem with this. Perhaps something along the lines of Julia compiler with ALL packages known to package manager installed doing search on AST level or deeper would work better in tricky cases?

Maybe this:

]add *

if you have RAM and CPU cycles to burn.

julia> using Images

julia> N0f8
Normed{UInt8,8}

julia> N0f8.name.module
FixedPointNumbers

If you just say using Images then you should get all the types you need for most work. But of course, loading the “big package” takes time, and it can indeed be useful to be able to discover the minimal set of packages you need for the focused task.

4 Likes

I’ve opened a JuliaHub issue to track this as a potential code search enhancement: https://github.com/JuliaComputing/JuliaHub/issues/57

1 Like

I was following the manual at https://juliaimages.org/latest/install/, perhaps too mindlessly. It was not clear what is the structure of packages in JuliaImages. The first example on that page starts with:

using FileIO

and there is no

using Images

on that page nor the next one, where N0f8 is introduced. I know it should be obvious, but for some reason it wasn’t for this noob.

2 Likes

That’s useful feedback, thanks for explaining what you were looking at! Nothing on that page actually requires you to say using Images but perhaps we should. Any suggestions about where it would be most helpful?

These comments from newbies are more useful than you could know, keep 'em coming! The most helpful thing to do would be to click on the “edit on GitHub” link in the docs and then either (1) make a change or (2) just file an issue saying “I was confused about x on this page, please help!”

2 Likes

I’m a bit reluctant to propose changes since these are my early days with actually using Julia and I’m moving in a haze of confusion and making rookie mistakes every move. I will try to expand beyond a few pull requests with minor grammar corrections.

Doc changes are actually prime for novice contributions. The whole point of docs is to make it easy to understand (especially for newcomers). As such, newcomers are usually write some of the best documentation since they know what they need.

4 Likes

Even if you don’t create improvements, you can do this:

  • click on “edit on github”
  • put your cursor in the spot where you got confused
  • type “This confused me. What is N0f8?”
  • submit it as a “pull request.”

We’ll treat that as an issue report rather than a fix. But the advantages for us are that we won’t forget to deal with it, whereas things posted here get lost to the sands of time if someone doesn’t fix it immediately.

9 Likes

Hi Paul, just to reiterate what others have said — points of confusion are probably bugs in the documentation. So if you’re willing, do make a big list of them and we can help file them with appropriate packages as necessary.

I think the julia community and ecosystem has entered a phase of growth where we need better tutorial and how-to style documentation. This is one of the areas where new users can help us most!

3 Likes

Hi Chris, some of them are, but in my case a lot of them are the result of impatience to have something working quick. I will try to contribute to Julia documentation. In this case, I made a pull request, which is already merged: https://github.com/JuliaImages/juliaimages.github.io/pull/137

3 Likes

I would suggest

parentmodule(N0f8)

instead.

Don’t worry, PRs are reviewed before merging, and you will be given suggestions on how to improve them if necessary. Most projects appreciate PRs even if they require quite a bit of handholding, because it means that someone is looking at the code/docs and they are happy to draw people in.

4 Likes