Move size_zero() calls after other consistency checks (A-I)#1758
Move size_zero() calls after other consistency checks (A-I)#1758bob-carpenter merged 2 commits intodevelopfrom
Conversation
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
|
It turns out that moving the |
bob-carpenter
left a comment
There was a problem hiding this comment.
Thanks so much for the heroic amount of error behavior fixes here. I was exhausted just after scrolling to check the new orders were right. And thanks also for fixing so much of the doc and code formatting around these changes.
| return 0; | ||
| } | ||
|
|
||
| using std::atan; |
There was a problem hiding this comment.
[comment]
Just a comment because you're fixing so much of the style, but not worth going in and changing for this PR.
I'd like to see using statements either all piled together at the top of the function or pushed down to just before the symbol is used.
There was a problem hiding this comment.
Up to now they were placed inconsistently, at least my change put them in the same place. I can move them to the top in the future.
| * @param mu (Sequence of) location(s). | ||
| * @param sigma (Sequence of) scale(s). | ||
| * @return The log of the product of densities. | ||
| * @tparam T_scale Type of scale. |
There was a problem hiding this comment.
[comment]
We want to head toward lower case and no periods for phrases that are not complete sentences.
There was a problem hiding this comment.
Yes, that's where I'm heading to. I think what happened here is that I started fixing this file, then noticed it was one of the deprecated ones and forgot to undo completely my changes.
|
Everything's been very inconsistent in terms of formatting. It's
especially great that you're fixing the behavior.
…On Thu, Mar 5, 2020 at 11:06 AM Marco Colombo ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In stan/math/prim/prob/cauchy_lccdf.hpp
<#1758 (comment)>:
> check_not_nan(function, "Random variable", y);
check_finite(function, "Location parameter", mu);
check_positive_finite(function, "Scale parameter", sigma);
check_consistent_sizes(function, "Random variable", y, "Location parameter",
mu, "Scale Parameter", sigma);
+ if (size_zero(y, mu, sigma)) {
+ return 0;
+ }
+
+ using std::atan;
Up to now they were placed inconsistently, at least my change put them in
the same place. I can move them to the top in the future.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1758?email_source=notifications&email_token=AAZ2D74MEUPAGOYZZUENS3TRF7EZFA5CNFSM4LBNCOB2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCYETH2I#discussion_r388394988>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZ2D7YB2WFJZNE5MWQT6HDRF7EZFANCNFSM4LBNCOBQ>
.
|
Summary
This is the first of two PRs that deals with moving the
size_zerocalls after the other consistency checks on function arguments. This covers all distributions with names starting A-I.This also improves the consistency of the placement of the
using std::statements and the declaration of theoperands_and_partialsvariable. This came about as in many cases these lines of code were in between thesize_zerochecks and the other consistency checks, so they had to be moved anyway. Now all distribution files look very similar in their first few chunks, which is a small added benefit, I think.Tests
No new tests. The distribution test framework already contains tests for input vectors of size zero (search for
test_length_0_vector).Side Effects
None.
Checklist
Math issue Move size_zero checks after consistency checks on arguments #1757
Copyright holder: Marco Colombo
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 test-math-dependencies)make doxygen)make cpplint)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested