-
Notifications
You must be signed in to change notification settings - Fork 811
Replace deprecated assert_almost_equal with assert_allclose in GNM tests #5290
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,3 +53,5 @@ benchmarks/results | |
| .idea | ||
| .vscode | ||
| *.lock | ||
| venv/ | ||
| package/doc/sphinx/_build/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| """ | ||
| Benchmarks for the EinsteinMSD analysis module. | ||
| """ | ||
|
|
||
| import numpy as np | ||
| import MDAnalysis as mda | ||
| from MDAnalysis.analysis import msd | ||
| from MDAnalysis.tests.datafiles import RANDOM_WALK_TOPO, RANDOM_WALK | ||
|
|
||
|
|
||
| class EinsteinMSDCustom: | ||
| """ | ||
| Benchmark for Mean-Squared Displacement (EinsteinMSD). | ||
|
|
||
| The trajectory is created by using random forces | ||
| that are generated from a normal distribution | ||
| and then cumulatively summed to simulate a real random walk. | ||
| """ | ||
|
|
||
| unit = "ms" | ||
| description = ( | ||
| "Performance of EinsteinMSD calculation using " | ||
| "custom n_atoms and range of n_frames." | ||
| ) | ||
|
|
||
| timeout = 300.0 | ||
|
|
||
| param_names = ["n_frames", "fft"] | ||
| params = ([100, 1000, 5000], [True, False]) | ||
|
|
||
| def setup(self, n_frames, fft): | ||
| """Setup method for MSD benchmark with custom number of frames.""" | ||
| n_atoms = 100 | ||
|
|
||
| rng = np.random.default_rng(42) | ||
|
|
||
| # Random forces are sampled from a normal distribution | ||
| steps = rng.standard_normal((n_frames, n_atoms, 3), dtype=np.float32) | ||
|
|
||
| # Cumulative sum is taken to simulate positions over time | ||
| res = np.cumsum(steps, axis=0) | ||
|
|
||
| self.u = mda.Universe.empty(n_atoms, n_frames=n_frames, trajectory=True) | ||
| self.u.trajectory.set_array(res) | ||
|
|
||
| def time_msd_run_custom(self, n_frames, fft): | ||
| """ | ||
| Benchmark calculation of Mean-Squared Displacement | ||
| using a custom trajectory. | ||
| """ | ||
| msd_var = msd.EinsteinMSD(self.u, select="all", fft=fft) | ||
| msd_var.run() | ||
|
|
||
|
|
||
| class EinsteinMSDExample: | ||
| """ | ||
| Benchmark for Mean-Squared Displacement (EinsteinMSD) | ||
| using the RANDOM_WALK example trajectory provided in the MDAnalysis testsuite. | ||
|
|
||
| The files for the trajectory can be found in the library at : | ||
| RANDOM_WALK - mdanalysis/testsuite/xyz_random_walk.xtc | ||
| RANDOM_WALK_TOPO - mdanalysis/testsuite/RANDOM_WALK_TOPO.pdb | ||
| """ | ||
|
|
||
| unit = "ms" | ||
| description = ( | ||
| "Performance of EinsteinMSD calculation using RANDOM_WALK_TOPO and RANDOM_WALK" | ||
| ) | ||
|
|
||
| timeout = 300.0 | ||
|
|
||
| param_names = ["fft"] | ||
| params = [True, False] | ||
|
|
||
| def setup(self, fft): | ||
| """Setup method for MSD benchmark with RANDOM_WALK example.""" | ||
| self.u = mda.Universe(RANDOM_WALK_TOPO, RANDOM_WALK) | ||
|
|
||
| def time_msd_run_simple(self, fft): | ||
| """ | ||
| Benchmark calculation of Mean-Squared Displacement | ||
| using the example trajectory RANDOM_WALK. | ||
| """ | ||
| msd_var = msd.EinsteinMSD(self.u, fft=fft) | ||
| msd_var.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't know if we should be adding these - at the very least please add descriptions about what is being ignored & why like the rest of the file.
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.
Thanks for pointing that out!
I'll add proper descriptions explaining what is being ignored and why, to match the style used in the rest of the .gitignore file. I'll update the PR shortly.