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

Even better docs #488

Merged
merged 19 commits into from
Oct 25, 2019
Merged

Even better docs #488

merged 19 commits into from
Oct 25, 2019

Conversation

glwagner
Copy link
Member

@glwagner glwagner commented Oct 19, 2019

This PR rewrites much of the docs, adds a show function for Model and various boundary conditions structures (which fixes very long output in the docs), and updates many of the examples to be docs-friendly.

The docs are still very much preliminary even after the updates in this PR. Once this PR is merged, I will open an issue to define a roadmap for getting the docs to the place we need them to be.

@codecov
Copy link

codecov bot commented Oct 19, 2019

Codecov Report

Merging #488 into master will decrease coverage by 0.46%.
The diff coverage is 7.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #488      +/-   ##
==========================================
- Coverage    73.2%   72.73%   -0.47%     
==========================================
  Files          37       37              
  Lines        1709     1720      +11     
==========================================
  Hits         1251     1251              
- Misses        458      469      +11
Impacted Files Coverage Δ
src/models.jl 85.71% <0%> (-2.53%) ⬇️
src/boundary_conditions.jl 75% <0%> (-5.6%) ⬇️
src/AbstractOperations/computations.jl 76% <0%> (ø) ⬆️
src/utils.jl 73.14% <0%> (-3.56%) ⬇️
src/fields.jl 53.33% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20f9d08...dd07cd1. Read the comment docs.

Copy link
Member

@ali-ramadhan ali-ramadhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! Still waiting for docs to build on my laptop so I can look at the examples, but looks good to merge. I agree it'll be good to discuss what the docs should look like.

I was hoping to find a citation solution to use in place of all the \citet and \citep commands, but don't think I have the time to work on that so maybe manual formatting is the way to go for now?

I think physics.md contains too many different topics but that can be left to another PR.

Should we refer to the package as Oceananigans.jl or just Oceananigans? Oceananigans without backticks might be better as it's not code or a keyword argument, etc.

Comment on lines +69 to +72
#"Appendix" => [
#"Staggered grid" => "manual/staggered_grid.md",
#"Fractional step method" => "manual/fractional_step.md",
#],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep them around as appendices but you were suggesting they're not suitable as appendices in their current form?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think they are helpful to users yet. They need a bit of work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more a matter of opinion.

But my name is not the only one appearing on the docs so I'll work on them until everyone is happy with the appendices.

Copy link
Member Author

@glwagner glwagner Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right in general that whether or not docs are more useful than harmful is an opinion... ! But I'm not talking about the content (which you wrote). I'm talking about the way that I chopped up the overleaf and pasted the text in. It's chaotic and random and there's no reference to it in the main part of the docs. It's just noise at this point, the basic work of shaping the content into an appendix and referencing it remains.

src/models.jl Outdated
Comment on lines 87 to 102
function ordered_dict_show(dict, padchar)
if length(dict) == 0
return string(typeof(dict), " with no entries")
elseif length(dict) == 1
return string(typeof(dict), " with 1 entry:", '\n',
padchar, " └── ", dict.keys[1], " => ", typeof(dict.vals[1]))
else
return string(typeof(dict), " with $(length(dict)) entries:", '\n',
Tuple(string(padchar,
" ├── ", name, " => ", typeof(dict[name]), '\n')
for name in dict.keys[1:end-1]
)...,
padchar, " └── ", dict.keys[end], " => ", typeof(dict.vals[end])
)
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably belongs in utils.jl?

@ali-ramadhan
Copy link
Member

Examples starting to look great!

We should probably add show functions for a few more structs like JLD2OutputWriter but maybe there's a way to suppress the printing? I tried adding a semicolon last weekend but that didn't help. I'll ask on the #documentation channel.

Few more comments on the examples:

  1. In ocean_convection_with_plankton.jl you say "Finally, we end the simulation after 1 day." but end_time = day / 2. Might also be good to explain that Oceananigans exports day. I should probably add docstrings to second, minute, hour, day.

  2. Might be better to use pcolormesh or contourf for the two_dimensional_turbulence.jl example plotting.

  3. Also might be good to add colorbars to the plots in the examples, but this can wait.

  4. All the colormaps are viridis. Again, this can wait.

@ali-ramadhan
Copy link
Member

We should also figure out how to get equation numbers and \eqref to work with KaTeX. KaTeX has pretty good documentation so shouldn't be too hard.

But if KaTeX is limiting us, we can switch back to the MathJax backend through Documenter.

image

the momentum and tracer equations are are solved rotates at a constant rate around a
vertical axis, such that
```math
\bm{f} \equiv f \bm{\hat z}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use = for the beta-plane definition but \equiv for the f-plane?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a typo

@glwagner
Copy link
Member Author

glwagner commented Oct 21, 2019

KaTeX cannot do equation numbers or references yet. There are a number of issues open on katex github about this.

I think to suppress output you’d have to add a line with ‘nothing’. But this is silly, so yes, show for the output writers is important.

I tried to keep the plotting simple and barebones so 1. we don’t distract from the point of the example, which is to demonstrate Oceananigans usage (not to demonstrate plotting) and 2. so the examples are easy to maintain. I agree that colorbars are useful for interpreting output, but we don’t interpret output in the examples.

I think viridis is an acceptable colormap, but I’m also happy to pick a prettier one. As I noted above, I think we should keep plotting simple and involving as few characters as possible so the examples are maximally useful in demonstrating how Oceananigans is used. (There’s really too much code devoted to plotting as is, which we should fix by shipping plotting recipes with Oceananigans.)

I thought the package name is Oceananigans.jl? What is convention?

Typos noted, I will fix before merging.

@ali-ramadhan
Copy link
Member

ali-ramadhan commented Oct 21, 2019

I tried to keep the plotting simple and barebones so 1. we don’t distract from the point of the example, which is to demonstrate Oceananigans usage (not to demonstrate plotting) and 2. so the examples are easy to maintain. I agree that colorbars are useful for interpreting output, but we don’t interpret output in the examples.

True but using pcolormesh or contourf with a colorbar adds at most a few lines (for the 2D turbulence example). I believe most people don't actually read examples from start to finish and just quickly scroll through the text to skim the code and any plots. So having a plot with some labels might help to these potential users won't have to search the text to figure out what they're looking at.

There’s really too much code devoted to plotting as is, which we should fix by shipping plotting recipes with Oceananigans.

That might help for the complicated plots although I think it'll be useful to keep some introductory examples that use the regular plotting functions so users can see how to go about plotting their own simulations without the use of our plotting recipes.

I thought the package name is Oceananigans.jl? What is convention?

Maybe getting rid of the backticks might help as it looks pretty distracting in the docs with backticks:
image

@glwagner
Copy link
Member Author

glwagner commented Oct 21, 2019

True but using pcolormesh or contourf with a colorbar adds at most a few lines (for the 2D turbulence example)

It was a conscious choice on my part (not laziness) to use imshow rather than pcolormesh for exactly the purpose of eliminating "a few lines". I reluctantly added the grid in some of the other examples, in part because I did not want to mislead about the grid locations of w and tracers (possibly we can reduce plotting in the other examples too, which would be desirable).

Note that the quantity of lines is not the only issue; the issue is that one cannot ignore any lines when reading a code, so that each line of code has the potential to distract / confuse and thus should be absolutely meaningful and clear. This issue is especially acute for users who may already be stressed by interpreting code in an unfamiliar language.

If we could fence parts of the code off and say "don't read this part because its just for plotting", we could maybe do that, but I think it's strange. Better in my opinion to keep plotting as minimalistic as possible to maximize readability. I really think the value of an example is a strongly diminishing function of its number of lines and its syntactical complexity.

I think plotting could be important (or very important) if the plot output is crucial to the value of an example. This could be the case if we want to demonstrate the physics of the code (and I think this could be a good idea). At the moment, our examples do not explain the physics or physical motivation behind the examples. Instead, I designed the examples to be utilitarian to demonstrate valid syntax patterns for setting up a model. The physical aspects of the examples is incidental and not explained or justified (though I do think that for users who understand the physics, this "extra sugar" could be useful --- while causing no harm to users who do not understand the physics). Thus most of the plots simply demonstrate that the code "did something". They don't show anything meaningful in my opinion.

I am all for more physically meaningful examples. But we should always think carefully about the purpose of the examples and each line of code they contain. Some of our examples should be about code and not physics --- because this better serves users who do not understand the physics (who would be distracted by lengthy physical justifications / discussions in the examples).

If "vorticity" as a title is not clear enough for the two-dimensional turbulence example we can say "Heatmap of vorticity on an arbitrary scale"? Would that be more clear? The point of plotting vorticity is to demonstrate that the "diagnostic" that was defined is actually returning something (any significance of what was returned is just a bonus from the standpoint of that example, not a critical aspect of the example's purpose). Note that when I code things up I often use imshow for exactly this purpose; thus creating a plot with imshow as a means of quickly checking data could be a useful code pattern. Perhaps you disagree?

Note that technically the colormap used for examples is the user's default (not viridis) --- it doesn't show as viridis on my laptop, for example. But I appreciate that viridis is matplotlib default and thus what will appear in the online docs.

@ali-ramadhan
Copy link
Member

What you've done with the examples makes more sense now if viewed as utilitarian examples meant to show case how you can interact with the code.

For users who are trying to familiarize themselves with Julia, maybe it could help if we further split the time stepping and plotting so that all time stepping happens in the first n lines and afterwards some plotting happens so it's clearer to the user what is Oceananigans code and what is plotting code.

But yeah I'm happy with the examples in this PR. There will be plenty of opportunities to improve.

Should we merge this now? The docs have been improved, and would be good to start getting some feedback.

@glwagner glwagner merged commit cacb753 into master Oct 25, 2019
@glwagner glwagner deleted the glw/even-better-docs-for-joss branch October 25, 2019 03:13
arcavaliere pushed a commit to arcavaliere/Oceananigans.jl that referenced this pull request Nov 6, 2019
…s-for-joss

Even better docs

Former-commit-id: cacb753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants