Skip to content

Add missing unary plus and cleanup tests #2032

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

Merged
merged 6 commits into from
Aug 28, 2020
Merged

Conversation

rok-cesnovar
Copy link
Member

@rok-cesnovar rok-cesnovar commented Aug 24, 2020

Summary

Fixes #1888 by adding the unary plus. When adding tests for that I saw that we still have the _works_with_other_functions tests that are redundant after #1980 This advances #1886 but does not close it yet.

Tests

Added same tests as for minus()

Side Effects

/

Release notes

Added missing implementations for the unary plus.

Checklist

  • Math issue No implementation of plus(x) #1888

  • Copyright holder: Rok Češnovar, Univ. of Ljubljana

    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

@rok-cesnovar rok-cesnovar requested a review from t4c1 August 24, 2020 12:00
* @return result of unary plus of the input.
*/
template <typename T>
inline plain_type_t<T> plus(const T& x) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use perfect forwarding when returning the argument.

Copy link
Member Author

Choose a reason for hiding this comment

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

Like this?

template <typename T>
inline plain_type_t<T> plus(T&& x) {
  return std::forward(x);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, also make the return type T - we don't need plus to eval its argument.

@rok-cesnovar
Copy link
Member Author

@serban-nicusor-toptal can we try if gelman-group-linux can now run the Clang-format and Linting & Doc checks again? If we are unlucky with Linux AWS instances like we are now and there are none free, the jobs are all stalled.

If there is an issue with the machine, we can see if we can fix it.

@serban-nicusor-toptal
Copy link
Contributor

serban-nicusor-toptal commented Aug 24, 2020

Hey @rok-cesnovar the pool was enough, there were no issues with it not being able to find machines.
I either introduced a bug yesterday or there were some connectivity issues today, I've recreated the fleets now and everything is working fine.
Sorry for the waiting!
PS: I think gelman-linux should run everything just fine now.

@rok-cesnovar
Copy link
Member Author

@serban-nicusor-toptal thanks!

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 4.19 4.23 0.99 -1.02% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.0 0.04% faster
eight_schools/eight_schools.stan 0.09 0.09 0.98 -2.13% slower
gp_regr/gp_regr.stan 0.2 0.2 0.99 -1.02% slower
irt_2pl/irt_2pl.stan 5.25 5.28 0.99 -0.57% slower
performance.compilation 88.81 87.58 1.01 1.38% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.27 8.21 1.01 0.7% faster
pkpd/one_comp_mm_elim_abs.stan 27.02 27.11 1.0 -0.34% slower
sir/sir.stan 129.33 130.82 0.99 -1.15% slower
gp_regr/gen_gp_data.stan 0.05 0.05 0.99 -1.16% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.34 3.33 1.0 0.15% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.38 0.4 0.94 -6.39% slower
arK/arK.stan 1.84 2.54 0.72 -38.47% slower
arma/arma.stan 0.59 0.73 0.8 -24.3% slower
garch/garch.stan 0.62 0.73 0.84 -18.63% slower
Mean result: 0.95064261234

Jenkins Console Log
Blue Ocean
Commit hash: a74a277


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@rok-cesnovar rok-cesnovar requested a review from t4c1 August 28, 2020 06:17
@t4c1 t4c1 merged commit 6f7c059 into develop Aug 28, 2020
@rok-cesnovar rok-cesnovar deleted the feature/plus-cleanup-tests branch November 28, 2020 20:05
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.

No implementation of plus(x)
4 participants