Stan Test Structure


#1

Just need a bit of help making sure that I understand how the math tests are structured, or how they should be structured in an ideal world, plus a couple of questions. Let me know if I’m completely off here (obvious questions may follow).

Based on the guide in the wiki:

test/unit/math/mix/mat/util/autodiff_tester.hpp
Implements the reverse, forward, and mixed autodiff tests for a 1- or 2-parameter function. But still requires a test in test/unit/math/prim to test that the correct values are returned by the function.

  • If a function has a test specified with this framework, does that mean they don’t need tests in rev or fwd?
  • If the function has analytic derivatives, does that change whether/how this testing framework is used?
  • Are there limitations on the kinds of functions that can use this framework?

Next there are the frameworks for testing the vectorized versions of unary functions (i.e. */mat/:

test/unit/math/prim/mat/vectorize/prim_scalar_unary_test.hpp
test/unit/math/rev/mat/vectorize/rev_scalar_unary_test.hpp
test/unit/math/fwd/mat/vectorize/fwd_scalar_unary_test.hpp
test/unit/math/mix/mat/vectorize/mix_scalar_unary_test.hpp

These only test whether the vectorization process has affected the function in some way, and still requires tests for the function in */scal/

For all other cases, a function needs to have a test in prim, fwd, rev, and mix

Have I missed anything?


#2

Correct.

No.

There shouldn’t be, but if there are, we want to build out the testing framework to cope. I’ve just been building it out as I go.

The real goal here is to get all the forward-mode autodiff tested, then turn on Riemannian HMC.

Yes.

I think the vectorized tests probably cover the scalar case, too, but I’m not 100% sure.