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

Feature/lb constrain matvar varmat tests #2382

Conversation

bbbales2
Copy link
Member

Summary

@SteveBronder I was gonna do this directly on the lb_constrain-matvar branch but it ended up being big enough to be separate.

This:

  1. Updates the matvar tests to support std::vector<Eigen::Matrix<T, R, C>> types. This does not support std::vector<std::vector<...>> recursive types.
  2. Enables matvar tests for lb_constrain
  3. Add dimensionality checks to lb_constrain (since Math is doing all the work now)
  4. Tests everything

lb_free is failing to compile now though. I'm sending this back to you to implement. Merge this in the other lb_constrain branch when you're happy.

./runTests.py test/unit/math/prim/fun/lb_transform_test.cpp

Tests

I had to update the matvar test of tests quite a bit to make sure they were triggering in the right place

Release notes

Replace this text with a short note on what will change if this pull request is merged in which case this will be included in the release notes.

Checklist

  • Math issue Allow for std::vector arguments to expect_ad_matvar #2333

  • Copyright holder: Columbia University

    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

}

// matrix[], matrix
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are these in brackets like this?

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 was just marking off tests with arguments in Stan syntax so I could keep them straight in my head. We can delete these comments, of course. I just left them cause it reminds me what the code is doing.

Comment on lines +415 to +418
if(!any_varmat) {
SUCCEED(); // If no varmats are created, skip this test
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

When would this happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

If a function was signature vector, real and these tests tried to check the matvar, varmat version of the function (which it will), then the matvar, matvar and matvar, varmat both use the C++ types Eigen::Matrix<var, -1, 1>, var so there's no point testing it.

It's important to actually not test this too, cause the return type will be matvar if there are not varmat arguments.

Three different notations for argument types in one sentence! Nice!

Comment on lines +407 to +408
auto A_mv_tuple = std::make_tuple(convert_to_matvar<Types>(x)...);
auto A_vm_tuple = std::make_tuple(convert_to_varmat<Types>(x)...);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would a better name be make_matvar/varmat_compatible? Convert makes it sound like it's always going to transform to something else

* @param x not used, only types are used.
*/
template <typename ReturnType, typename Type, require_matrix_t<Type>* = nullptr>
void check_return_type(const std::vector<ReturnType>& ret,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did this get deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced by

if(is_var_matrix<T_mv_ret>::value ||
(as discussed on Slack)

@SteveBronder SteveBronder merged commit 558530e into feature/lb_constrain-matvar Feb 22, 2021
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