-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Refactor/clang tidy cleanup #1340
Conversation
…stable/2017-11-14)
…h into refactor/clang-tidy-cleanup
…xp1~20180509124008.99 (branches/release_50)
(stat_comp_benchmarks/benchmarks/gp_pois_regr/gp_pois_regr.stan, 1.0) |
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 great, the changes for braces are all fine.
There are a few files where we are changing some typedefs to using but some are left as typedefs. For consistency I think we should change the rest to using also. No need to change all the typedefs, I just feel that mixing both in the same file should be avoided.
stan/math/fwd/mat/fun/typedefs.hpp
Outdated
@@ -10,18 +10,18 @@ namespace math { | |||
|
|||
typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>::Index size_type; |
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.
Can we do this one manually so its consistent?
stan/math/fwd/mat/fun/typedefs.hpp
Outdated
@@ -10,18 +10,18 @@ namespace math { | |||
|
|||
typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>::Index size_type; | |||
|
|||
typedef Eigen::Matrix<fvar<double>, Eigen::Dynamic, Eigen::Dynamic> matrix_fd; | |||
using matrix_fd = Eigen::Matrix<fvar<double>, Eigen::Dynamic, Eigen::Dynamic>; | |||
|
|||
typedef Eigen::Matrix<fvar<fvar<double> >, Eigen::Dynamic, Eigen::Dynamic> |
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.
This one too.
stan/math/mix/mat/fun/typedefs.hpp
Outdated
@@ -9,18 +9,18 @@ | |||
namespace stan { | |||
namespace math { | |||
|
|||
typedef Eigen::Matrix<fvar<var>, Eigen::Dynamic, Eigen::Dynamic> matrix_fv; | |||
using matrix_fv = Eigen::Matrix<fvar<var>, Eigen::Dynamic, Eigen::Dynamic>; | |||
|
|||
typedef Eigen::Matrix<fvar<fvar<var> >, Eigen::Dynamic, Eigen::Dynamic> |
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.
For consistency please convert this one to using also.
@@ -28,7 +28,7 @@ namespace math { | |||
*/ | |||
template <typename F, typename T1, typename T2, typename T_t0, typename T_ts> | |||
struct coupled_ode_observer { | |||
typedef return_type_t<T1, T2, T_t0, T_ts> return_t; | |||
using return_t = return_type_t<T1, T2, T_t0, T_ts>; | |||
|
|||
typedef operands_and_partials<std::vector<T1>, std::vector<T2>, T_t0, T_ts> |
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 am just going to leave "using" for further comments where we can manually replace typdef.
stan/math/prim/mat/fun/log_mix.hpp
Outdated
const T_theta& theta, | ||
const std::vector<Eigen::Matrix<T_lam, R, C> >& lambda) { | ||
const std::vector<Eigen::Matrix<T_lam, R, C>>& lambda) { | ||
static const char* function = "log_mix"; | ||
typedef typename stan::partials_return_type< |
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.
using?
@@ -24,8 +24,9 @@ return_type_t<T_y, T_loc, T_scale, T_inv_scale> exp_mod_normal_lpdf( | |||
typedef partials_return_type_t<T_y, T_loc, T_scale, T_inv_scale> |
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.
using line 23
@@ -21,8 +21,9 @@ return_type_t<T_y, T_loc, T_scale, T_shape> pareto_type_2_cdf( | |||
typedef partials_return_type_t<T_y, T_loc, T_scale, T_shape> |
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.
using
@@ -21,8 +21,9 @@ return_type_t<T_y, T_loc, T_scale, T_shape> pareto_type_2_lccdf( | |||
typedef partials_return_type_t<T_y, T_loc, T_scale, T_shape> |
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.
using
@@ -22,8 +22,9 @@ return_type_t<T_y, T_loc, T_scale, T_shape> pareto_type_2_lcdf( | |||
typedef partials_return_type_t<T_y, T_loc, T_scale, T_shape> |
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.
using
@@ -14,37 +14,37 @@ typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>::Index size_type; | |||
* The type of a matrix holding <code>var</code> |
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.
using at line 11
…xp1~20180509124008.99 (branches/release_50)
@rok-cesnovar thanks for the review! I think I cleaned up all the rest of the typedefs. I left the ones in the MPI code that are used in a macro because I was worried about touching those. But everywhere else should be good to go |
…gs/RELEASE_500/final)
(stat_comp_benchmarks/benchmarks/gp_pois_regr/gp_pois_regr.stan, 1.01) |
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.
LGTM. Agreed on leaving the ones you are not sure about. Thanks!
Edit: Something weird is going on with the Jenkinsbot so I move the branch over to the main repo
Summary
Running clang-tidy with the checks below. This refactor is only aesthetic and does not change how any of the code is executed.
readability-braces-around-statements:
modernize-use-using:
everywhere clang-tidy can replace a
typedef
with ausing
it will akatypedef double A;
becomesusing A = double;
modernize-use-nullptr:
using
nullptr
instead of NULLThe original PR also had a cleanup to return a braced init list but after looking at the I didn't like it
Tests
refactor is only aesthetic so no new tests
Checklist
Math issue Update internals to use more modern c++ #1308
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 doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested