-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Cleanup requires with macros #1794
Conversation
…tor to is_eigen and is_std_vector
…gs/RELEASE_500/final)
…gs/RELEASE_500/final)
…gs/RELEASE_500/final)
…stable/2017-11-14)
…gs/RELEASE_500/final)
@serban-nicusor-toptal it looks like the windows machines are taking a bit? Fine with it taking a while if there are a bunch of PRs but just a heads up |
Hey, one machine seems down. Going to get it up now to speed up the queue. Thanks for the notice! |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
…stable/2017-11-14)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
@t4c1 would you have time to give this a lookover? It looks like a lot but it's mostly just moving stuff around and a good bit of docs. The only other change is that That and I updated the code for the functions which were giving warnings on doxygen so that we could use the warnings are errors flag in doxygen. Now if anyone does not doc correctly it will error out |
stan/math/fwd/fun/sum.hpp
Outdated
* @return Sum of vector entries. | ||
*/ | ||
template <typename T> | ||
inline fvar<T> sum(const std::vector<fvar<T>>& m) { | ||
if (m.size() == 0) { | ||
inline fvar<T> sum(const std::vector<fvar<T>>& v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you rename all these variables? I don't think these have anything to do with requires. This PR is already large enough, so if you think these are needed, they should be put in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just to fix the doxygen warnings but I can undo them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To undo these I will need to turn off the doxygen option to promote warnings to errors that I added in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is so, I am ok with leaving those in. I did not understand these are connected with docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, what kind of warnings did renaming a few variables solve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you already reverted those. Lets leave them for another PR.
stan/math/prim/meta.hpp
Outdated
/** \addtogroup type_trait | ||
* @{ | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this just moved from stan/math.hpp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is now replaced with docs on each require(that are generated with macros)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this just moved from stan/math.hpp?
I meant the whole ~150 lines of docs.
…stable/2017-11-14)
…cleanup/require_base
…gs/RELEASE_500/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
STAN_ADD_REQUIRE_UNARY_INNER(floating_point, std::is_floating_point, | ||
require_stan_scalar_real); | ||
STAN_ADD_REQUIRE_UNARY(index, std::is_integral, require_stan_scalar_real); | ||
STAN_ADD_REQUIRE_UNARY_INNER(index, std::is_integral, require_stan_scalar_real); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it is not part of this PR, but why do we have require_index
for is_integral
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh I put that in there whenever I was working on stan upstream stuff, I can change this
stan/math/fwd/fun/sum.hpp
Outdated
* @return Sum of vector entries. | ||
*/ | ||
template <typename T> | ||
inline fvar<T> sum(const std::vector<fvar<T>>& m) { | ||
if (m.size() == 0) { | ||
inline fvar<T> sum(const std::vector<fvar<T>>& v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, what kind of warnings did renaming a few variables solve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!. Just one question
It's something weird in doxygen
|
…e_generics and give correct includes to other headers
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Summary
This PR cleans the
requires*
meta programs to be auto generated using macros. This PR should be fully backwards compatible with the current method. More importantly, the documentation for these has been cleanup up such that it's much easier to go through and look for certain types of requires.The macros are
STAN_ADD_REQUIRE_UNARY
: For validating a single type satisfies a type trait.STAN_ADD_REQUIRE_BINARY
: For type traits that require comparing two types.Both of these have a
*_INNER
macro that defines requires to check thescalar_type
andvalue_type
of arbitrary types. This is more useful for binary requires where we want to check that two matrices for instance have the samevalue_type
. These are labeled asrequire_vt/st_*
i.e.require_vt_same<T, S>
STAN_ADD_REQUIRE_CONTAINER
: For defining requires likerequire_eigen_t<>
andrequire_eigen_vt<>
.Tests
All the current tests should pass. One important thing to check is the documentation via
make doxygen
.Side Effects
These macros will be floating in the background, but I think they are named such that it would be hard to accidentally hit them.
Release notes
Refactoring the
require_*
metaprograms to reduce code duplication and increase documentation.Checklist
Math issue Breakup require_generics.hpp into multiple files #1739
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
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested