Skip to content
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

clean up mean_function tests without reactivating AD #315

Merged
merged 3 commits into from
Apr 8, 2022

Conversation

st--
Copy link
Member

@st-- st-- commented Apr 7, 2022

No description provided.

@codecov
Copy link

codecov bot commented Apr 7, 2022

Codecov Report

Merging #315 (37aeb0a) into master (598cd63) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #315   +/-   ##
=======================================
  Coverage   97.64%   97.64%           
=======================================
  Files          10       10           
  Lines         382      382           
=======================================
  Hits          373      373           
  Misses          9        9           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 598cd63...37aeb0a. Read the comment docs.

@@ -1,47 +1,53 @@
@testset "mean_functions" begin
Copy link
Member

Choose a reason for hiding this comment

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

A bit simpler to just generate them once:

Suggested change
@testset "mean_functions" begin
@testset "mean_functions" begin
Random.seed!(123456)
N = 5
D = 3
x1 = randn(N)
xD = ColVecs(randn(D, N))
xD′ = RowVecs(randn(N, D))

The Mersenne RNG is not the default anymore, so it seems slightly strange to enforce it explicitly. In general, RNGs are reset after each testset so it should be sufficient to just set the seed once at the top/in runtests.jl but that's not part of the PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the exact random numbers matter, then it makes sense to explicitly state which random number generator you use (otherwise your tests might suddenly fail once julia moves to a new default).

If the exact random numbers don't matter, then it shouldn't even need the Random.seed! ... no?

Copy link
Member

Choose a reason for hiding this comment

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

No. The random numbers may be (and probably are) different for different Julia versions and hardware architectures anyway. Setting a seed is only useful to avoid spurious test failures with numerically bad samples - they are quite rare here I assume but without any seed we might eventually get them in some test run.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, hypothetically, you might still eventually get that issue at some julia version upgrade.
What's the problem with keeping the MersenneTwister then ? Why would it be needed that I add this one additional change?

Copy link
Member

Choose a reason for hiding this comment

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

It's not strictly necessary but a) it seems simpler and b) allows us to test the methods with the default, and hence most likely used, RNGs. b) can also lead to a speed-up in more recent Julia versions.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it should be necessary in this PR. please change separately if you care.

Copy link
Member

Choose a reason for hiding this comment

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

I really don't understand why you're so hesitant to take up any suggestions and basically always suggest to "just do it later". This is very frustrating, and in my opinion also unproductive. In this PR these lines are changed so it's the perfect opportunity for such improvements, in particular if they are so simple.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just clean something up as I go along is something that I thought at other times, too, only to get a comment from you complaining that I changed something else.

I'm hesitant to take up your suggestions because it's more work. Sure I could accept your suggestion, then I have to go and fix the other uses of rng. Maybe it would make it even better than what I proposed. But I don't have the time to make everything perfect! It gets to the point where it seems that proposing any change ends up taking hours of back and forth, even though it would have already improved a bit over the status-quo already.

The measure for whether a PR should be merged or not shouldn't be "is this the best it could possibly be?", only "does this improve over what we had before?" (implying it doesn't make anything else worse in the process).

test/mean_function.jl Outdated Show resolved Hide resolved
test/mean_function.jl Outdated Show resolved Hide resolved
test/mean_function.jl Outdated Show resolved Hide resolved
@st-- st-- requested a review from devmotion April 7, 2022 13:59
test/mean_function.jl Outdated Show resolved Hide resolved
@st-- st-- requested a review from devmotion April 7, 2022 14:13
@st-- st-- dismissed devmotion’s stale review April 7, 2022 14:19

Addressed comments, please approve

Comment on lines +2 to +6
rng = MersenneTwister(123456)
N, D = 5, 3
x1 = randn(rng, N)
xD_colvecs = ColVecs(randn(rng, D, N))
xD_rowvecs = RowVecs(randn(rng, N, D))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rng = MersenneTwister(123456)
N, D = 5, 3
x1 = randn(rng, N)
xD_colvecs = ColVecs(randn(rng, D, N))
xD_rowvecs = RowVecs(randn(rng, N, D))
Random.seed!(123456)
N, D = 5, 3
x1 = randn(N)
xD_colvecs = ColVecs(randn(D, N))
xD_rowvecs = RowVecs(randn(N, D))

@devmotion
Copy link
Member

I unsubscribed, please find another reviewer.

@st-- st-- requested review from willtebbutt and theogf April 8, 2022 13:28
@yebai
Copy link
Contributor

yebai commented Apr 8, 2022

Many thanks, @st-- for the nice improvements! I think it's ready to get merged.

Also many thanks to @devmotion for the thorough and thoughtful reviews all the time.

@yebai yebai merged commit b5f38ab into master Apr 8, 2022
@yebai yebai deleted the st/meanfunctiontest branch April 8, 2022 16:23
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.

3 participants