-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
fixes #346, replace copy args with refs #539
Conversation
Is there something wonky with Jenkins? The default build's been triggered for a while, but no details. Same for the next pull request. And there's nothing running from the stan-dev/stan repo. |
Yes. It is wonky. It looks like there are two things going on: the Windows box is down and Jenkins is waiting to shutdown. @sealtalts, it's probably in a condition where it can't shut down until the existing builds are finished. |
This has just been sitting for six days. Would someone mind reviewing? It should be relatively easy as it's just simple C++ updates. |
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.
Fixing the docs for as_bool is the important thing
* | ||
* <p>See https://en.wikipedia.org/wiki/N-sphere#Generating_random_points |
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.
Missing closing <p>
? Or should this even be here?
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.
Fixed.
stan/math/prim/scal/fun/as_bool.hpp
Outdated
* @return 1 if argument is equal to zero (or NaN) and 0 otherwise. | ||
* @tparam type of scalar | ||
* @param x value | ||
* @return true if value is equal to zero or NaN |
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 looks backwards. Returns true if value is not equal to zero. I don't think NaNs equal anything, so it should still return true there (should check me on 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.
Yes, that's backwards. I'll fix it.
Depends what you mean by equal. If you mean operator==
, then that's right, NaN == NaN
returns false, which is why we have is_nan()
. I'll try to rephrase to make sure the "equal to" isn't confused as being ==
applied to NaN.
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.
fixed
*/ | ||
template <typename T, typename TL> | ||
inline | ||
T lb_constrain(const T x, const TL lb) { | ||
inline T lb_constrain(const T& x, const TL lb) { |
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.
Seems like lb could be passed by reference too, but I suppose if it's a single number it won't matter.
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.
Ack no, I just missed that one. General drill is to pass primitives by value and everything else by reference. With templates, the idea is to use constant references, which works well in both situations (passing values by reference isn't such a big deal).
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.
fixed
stan/math/prim/scal/fun/step.hpp
Outdated
*/ | ||
template <typename T> | ||
inline int step(const T y) { | ||
inline int step(const T& y) { |
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.
Should this exist with int_step?
Also, int_step and step handle zero differently. Not sure it matters for doubles but it would for ints.
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.
Hmm, maybe there is a reason this is called int_step. Maybe it handles ints differently... Still seemed strange to me.
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.
That's a good catch. I think that's been wrong all along. The int_
should just be the return type. And we want the condition to be > 0
so that step(0)
is zero.
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.
fixed.
…x/0346-copy-to-reference-args
@bbbales2 I addressed the comments. Thanks for reviewing. Let me know if it's OK now. |
@bbbales2 --- would you mind looking over the changes to see if this is OK to merge? I can't merge it until the original reviewer approves (or an admin overrides the review). |
That's very confusing---I just added a comment and it seems to have kicked off the tests again. @seantalts --- any idea what's going on with the testing starting again here? |
Sure thing (Edit: oh wow I see your comment from 13 days ago. I'll pay more attention next time. My mistake) |
I don't think the step behavior ever got changed Re: #539 (comment) step(0) should be 0.0 to be consistent with the int_step function -- it still is how it was before. I'll approve it if you meant to leave it like this though. Sorry for delay! (I'll be watching this closely so whenever it gets in I'll get on it) |
Thanks---hadn't realized I missed that. I'll fix it. It's not super urgent, I just every now and then try to clear out lingering pull requests, especially if they're mine. |
…x/0346-copy-to-reference-args
Not a bug on the step function.
But it is confusing, so I made a note to flag the difference in behavior in the integer and double step functions: I also pulled in the latest develop and am retesting. If it passes, I'll merge if you approve. |
Looks good! |
Submission Checklist
./runTests.py test/unit
make cpplint
Summary:
Replaced arguments of form
(T x)
with(const T& x)
to avoid copies. Also cleaned up a lot of doc. Removedconst
modifier on some local argumens.Side Effects:
it should be faster :-)
Documentation:
cleaned it up where I saw it
Reviewer Suggestions:
anyone
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
Columbia University
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: