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

[WIP] adds contributor guides to the docs #2350

Merged
merged 5 commits into from
Apr 7, 2021
Merged

Conversation

SteveBronder
Copy link
Collaborator

Summary

This takes @bbbales2 #192 PR and adds it to the stan math docs. I broke things up a bit into separate sections and fleshed out an example based on Ben's stuff. I like the example because it's pretty much real Stan math code and I think makes it easier to see the context on how we use the special widgets etc. we have. I'd like to add another example that's a bit more complicated for something like multiply but I'll do that later. This still needs some heavy editing and I'll tag people for particular sections.

This also changes the settings in doxygen.cfg so that even if there are warnings the docs are still built. I think it's annoying that some versions of doxygen compile the docs fine while others don't. This is most entirely because of warnings like

stan/math/rev/functor/idas_integrator.hpp:63: warning: argument 'dae' from the argument list of stan::math::idas_integrator::solve has multiple @param documentation sections

Which comes from us having a lot of different specializations and doxygen having trouble working out the docs for each. So I set the WARN_AS_ERROR flag for doxygen to NO

# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
# a warning is encountered.
# The default value is: NO.

WARN_AS_ERROR          = NO

Release notes

Adds docs for new contributors

Checklist

  • Math issue #(issue number)

  • Copyright holder: Steve Bronder

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@SteveBronder
Copy link
Collaborator Author

You can make the docs locally by running make doxygen

@bbbales2
Copy link
Member

bbbales2 commented Feb 3, 2021

Nice nice! Yeah gimme bite size pieces and happy to add on.

}
```

### Holders
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tagging @t4c1 and @andrjohns can you both look this over to make sure it covers the problem and solution well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks fine to me.

2. If you are writing a function for reverse mode, pass values by `const&`
3. In prim, if you are confident and working with larger types, use perfect forwarding to pass values that can be moved from. Otherwise simply pass values by `const&`.

### Copying non-arena variables to lambdas used in the reverse pass
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bbbales2 can you add make_callback_ptr() stuff here?

Copy link
Member

Choose a reason for hiding this comment

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

Done!

Comment on lines +230 to +237
### Nested Stacks

### Scoped Stacks

As an aside, in order to get the actual vector result, Eigen defines the
`.eval()` operator, so `c.eval()` would return an actual `Eigen::VectorXd`.
Similarly, Math defines the `eval` function which will evaluate an Eigen
expression and forward anything that is not an Eigen expression.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wds15 would you have time to write about Stan's threading scheme for the allocators? I think that would be best to put here

Comment on lines 169 to 171
TL;DR: Use Stan's `require` type trait library for limiting a function's scope to certain types.

Reading from left to right, `require_not_st_var_t` requires that a signature's template does _not_ have a _scalar type_ that is Stan's `var` autodiff type. This line is exactly the same as
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[todo: me] add link to requires docs

an autodiff type from the argument `x`. The function `f` is called on the
reverse pass similarly to `reverse_pass_callback`.

## Argument Types
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe everything here should go in another page?

Comment on lines 526 to 537
## Reverse Mode

### Values

`value_of(x)` returns the values of the variable `x`. If `x` is not an
autodiff type, it simply forwards `x` along. The values of `x` have
the same shape as `x`. For reverse mode autodiff, values are `double`
variables. For higher order autodiff (`fvar<var>`, etc.) this is not
always the case. See `value_of_rec` for a different behavior.

### Values and adjoint extensions to Eigen

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should probs go somewhere else as well

@SteveBronder
Copy link
Collaborator Author

I'm going to try to restructure this a lil bit tmrw. I'd like to better structure this like Eigen's docs

@rok-cesnovar
Copy link
Member

Question: Do we want to add which checks to run locally before submitting a PR? Also a note on clang-format and the rest?
If yes I can handle that.

@SteveBronder
Copy link
Collaborator Author

Yeah that would be awesome! I think that would go under the testing section

@SteveBronder
Copy link
Collaborator Author

@rok-cesnovar if you have time to write up the PR stuff that would be rad but otherwise I think this is good to go!

@rok-cesnovar
Copy link
Member

Will do over the weekend.

@rok-cesnovar
Copy link
Member

Obviously that weekend has long passed. Lets merge this.

@SteveBronder SteveBronder merged commit b542337 into develop Apr 7, 2021
@SteveBronder SteveBronder deleted the docs/intro-guide branch April 7, 2021 14:06
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.

None yet

4 participants