-
-
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
Add missing scalar prim signatures #2612
Conversation
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
I can review this. The current failure is a bit worrisome---it looks like it just failed outright in the LLVM judging from the plea to submit a bug report:
|
Yeah, the tests were already passing but failed upstream because stan-dev/stan#3080 was required. Restarted the tests, should be ready for review. |
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.
A bunch of picky doc comments and some more substantive testing questions. My main concern is that all the promotion of integers is tested as that's been an ongoing problem for us with the standard library functions. Not something complicated, just integer tests for all arguments. So if it's binary, that's four cases of {double, int} x {double, int}.
@rok-cesnovar JFYI. This breaks the R packages that depend on |
Yeah, I know (it also fails upstream for the exact same reason - the fact that some std functions live in the global namespace). This branch will be merged together accompanied by a change in stanc3 that will add explicit stan::math:: namespace to all generated Stan Math. Also thanks for checking it. I love that we have up-to-date rstan now! |
For the benefit of anyone who is interested primarily in the Math development without following stanc3 super closely, this PR is motivated by an issue that can lead to programs that stanc3 compiles but the c++ compiler can't. For example, parameters {
real alpha;
real beta;
}
transformed parameters {
real beta_function = beta(alpha, beta)
} We allow users to define a variable called beta, but without the explicit namespacing this PR allows the C++ compilers fail to compile the function call of beta. |
…4.1 (tags/RELEASE_600/final)
This is now ready for re-review. Ignore the test failure as it fails upstream (we will need some coordination to merge this and stan-dev/stanc3#1011 together). |
Please ignore the review request. Testing with the Stanc3 changes revealed that we also have to add Stan Math support for standard library functions that support std::complex inputs (arg, abs, norm, conj, proj, polar, exp, log, log10, pow, sqrt and trigonometric functions). The implementations should be simple, just calling the std:: function. |
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
Added Also added tests for complex inputs for other complex functions: abs, exp, log, log10, sqrt and trigonometric. All models now compile with stan-dev/stanc3#1011 and this branch so this is ready for review. |
@bob-carpenter - could you take another look at 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.
looks good. thanks for dealing with this huge pr.
This should be OK to merge when tests pass. |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Summary
Adds missing scalar implementations for max, min, fmod, atan2 and pow to fix #2611.
Additionally, this adds a test that generates unit tests on the fly. These tests check that all supported stanc3 scalar signatures (excluding those that return complex numbers and _rng functions) compile in the stan::math namespace. Additionally, it also checks that nothing was placed on any var stack (no inputs get promoted to vars).
Example of a test that is generated:
The functions are called twice because I wanted to make sure I included the result in an EXPECT test so it does not get optimized out. This might not be needed, but I just wanted to be safe.
The entire test file that is generated is here: prim_sig_test.txt
This test would be run on Github Actions.
Tests
Adds a new signature test that can be run via
./runTests.py test/scalar_prim_sig
. This generates a unit test file that checks that all primitive scalar functions compile and that none of them gets promoted to vars.Side Effects
/
Release notes
Added implementations of max, min, fmod, atan2 and pow for scalar inputs to the stan::math namespace.
Checklist
Math issue Add stub functions for certain std:: functions #2611
Copyright holder: Rok Češnovar
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/)