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

made test_dres_convergence less likely to fail #1932

Merged
merged 1 commit into from
Jun 12, 2018

Conversation

zemanj
Copy link
Member

@zemanj zemanj commented Jun 11, 2018

Fixes #1931

Changes made in this Pull Request:

  • If MDAnalysisTests.analysis.test_encore.TestEncore.test_dres_convergence fails, a RuntimeWarning is thrown and the test is repeated 10 times.
  • Commented out printf(...) in CStochasticProximityEmbedding()

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@coveralls
Copy link

coveralls commented Jun 11, 2018

Coverage Status

Coverage decreased (-0.02%) to 89.793% when pulling 5945a1f on zemanj:dres_convergence into 9675f92 on MDAnalysis:develop.

@zemanj
Copy link
Member Author

zemanj commented Jun 11, 2018

Simply repeating the test 10 times on failure is certainly not an ideal solution, it simply decreases the likelihood of random failures. Maybe someone else comes up with a better idea.
The decreased coverage seems majorly BS to me.

@kain88-de
Copy link
Member

To the solution is to switch out the RNG into something we can reliably seed ourselves. This can be done by porting the c extensions into cython. Then using the numpy rng can always use the same seed. That will make the tests reproducible.

@zemanj
Copy link
Member Author

zemanj commented Jun 11, 2018

@kain88-de Porting the C extensions to Cython sounds quite cumbersome and probably overkill to me...
Personally, I'd always prefer a C code interfaced with Cython over a "pure" Cython implementation.

However, regarding the option of setting a seed externally: Even though the implementation of rand() is compiler-specific (or at least depends on libc), it might still be ok to set a fixed seed externally (only for testing, of course), since it is rather unlikely to hit one of the seeds that cause test failure (regardless of the rand() implementation). Adding that option should be a lot easier to accomplish than porting the entire extension to Cython.
Nevertheless, in case of a fixed seed, the functionality is only ever tested for that particular seed. Not sure whether that's a good idea.

@kain88-de
Copy link
Member

Nevertheless, in case of a fixed seed, the functionality is only ever tested for that particular seed. Not sure whether that's a good idea.

You can rerun with different seeds if you like. But that is overkill IMHO. For tests using fixed seeds is OK because we want to reliable setup the same environment for a test.

Adding that option should be a lot easier to accomplish than porting the entire extension to Cython.

Well yeah maybe. But random numbers make all of this a bit more complicated when one wants to do them right. I prefer to give users a consistent interface to any RNG within mdanalysis and the easiest way to achieve this is to go with the numpy rng's. This also allows to run the analysis with multiple processes and give each process it's own correctly seeded RNG.

@zemanj
Copy link
Member Author

zemanj commented Jun 11, 2018

@kain88-de Sounds convincing. I agree that having a consistent PRNG interface throughout the code should be the way to go. The current state of the stochasticproxembed extension is not satisfactory in that respect, and even less when taking into account both reproducibility and random number quality.

How would you like proceed with this? I'd suggest using this PR as a band-aid and open a separate issue regarding PRNG interfaces.

@kain88-de
Copy link
Member

make the seed an argument to the function. Then we can provide one for testing. This will make the tests more reproducible instead of just rerunning them and hoping it will work out.

@richardjgowers
Copy link
Member

@kain88-de what you're proposing is the better solution for this, but this PR fixes the problem with false negatives on PRs nicely, we should merge

@richardjgowers
Copy link
Member

70b9e9f

@zemanj looks like maybe your email isn't configured right?

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.

4 participants