-
Notifications
You must be signed in to change notification settings - Fork 38
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
Implemented "count in voxel" function #1643
Conversation
pytraj/all_actions.py
Outdated
""" | ||
|
||
lives_in_voxel = [] | ||
population = top.atom_indices(mask) |
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.
use traj.top
?
Adding top
to function argument was my poor design :(.
import numpy as np | ||
|
||
|
||
class Test(unittest.TestCase): |
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.
Since you're making several PRs, so it would be better to follow the "modern" way to write test, by using pytest's style.
- The class is not needed
- Change the name of
test_0
to some thing meaningful to you.
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.
How do I trigger testing locally? Right now I'm making changes directly to the package that is installed, then running the individual test scripts I'm writing. When I remove the class and if __name__ == __main__
clause and run the script with just the function definitions, the tests themselves do not get executed.
if __name__ == "__main__": | ||
unittest.main() |
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.
remove
pytraj/all_actions.py
Outdated
mask="", | ||
voxel_cntr=(0, 0, 0), | ||
voxel_size=5): | ||
"""for a voxel with center xyz and size voxel_size, find atoms that match a given mask |
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.
"for" -> "For"
@sastrys1 Looks great to me. I have only several minor comments. |
Please use pytest
cd tests
python3 -m pytest test_analysys/test_closet_atom.py -vs
…On Thu, Oct 5, 2023 at 4:50 PM sastrys1 ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In tests/test_analysis/test_count_in_voxel.py
<#1643 (comment)>:
> @@ -0,0 +1,65 @@
+import unittest
+from pytraj import *
+import pytraj as pt
+from utils import fn
+from pytraj.testing import aa_eq
+import numpy as np
+
+
+class Test(unittest.TestCase):
How do I trigger testing locally? Right now I'm making changes directly to
the package that is installed, then running the individual test scripts I'm
writing. When I remove the class and if __name__ == __main__ clause and
run the script with just the function definitions, the tests themselves do
not get executed.
—
Reply to this email directly, view it on GitHub
<#1643 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB645JQ77UT6CZEWIRUKBLX54MQVAVCNFSM6AAAAAA5UA2B3OVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTMNRQGY4TCMZQGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
||
# tests to see if function can find an atom if we search with a coordinate | ||
# very close to the atom's xyz coordinates | ||
def search_for_atom(self): |
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.
oh, for each test, you need to add test_
prefix (test_search_for_atom
), otherwise, pytest
won't be recognise it.
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.
https://github.com/Amber-MD/pytraj/actions/runs/6424481585/job/17445206646
e.g: click "Test with pytest" and search for your function's names. They are not in there.
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.
Cool, got the tests to work by adding the prefix and using your python3 -m pytest
command
@sastrys1 here is how github action run the test:
|
Thanks @sastrys1 very much! |
This analysis command is meant to be used with GIST analysis to estimate water residence time for a given region.
When running GIST on a trajectory, we get a list of voxels and their associated rotational/translational entropy of solvent atoms. We can focus on low-entropy voxels (which behave differently from the bulk) and find the population of solvent atoms in a voxel throughout the course of a simulation to measure how long it's taking for solvent molecules to equilibrate in and out of solvent pockets on the macromolecular interface (survival time correlation function).