-
Notifications
You must be signed in to change notification settings - Fork 661
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
Update distances.py #1275
Update distances.py #1275
Conversation
Thank you for working on this issue. Your change broke the test. Among the flow of errors, only that one is relevant:
The tests are run automatically by TravisCI, but you can run them locally to find issues faster. Have a look at our guide to read how. |
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 taking on this problem. I added a few quick comments, hopefully they are helpful as you go along.
package/MDAnalysis/lib/distances.py
Outdated
@@ -206,6 +206,81 @@ def _check_lengths_match(*arrays): | |||
if not all( a.shape == ref for a in arrays): | |||
raise ValueError("Input arrays must all be same shape" | |||
"Got {0}".format([a.shape for a in arrays])) | |||
|
|||
## NOT COMPLETE - NEED REFINEMENT | |||
def distance(atom1,atom2,box=None): |
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.
Please follow PEP8 style, here "leave space after commas".
package/MDAnalysis/lib/distances.py
Outdated
TODO: refinement of the array structure to take advantage of numpy arrays, and generalize the input var | ||
|
||
""" | ||
name1 = "bynum" + " " + str(atom1) # concatenate string for first selection |
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.
indentation error
package/MDAnalysis/lib/distances.py
Outdated
@@ -206,6 +206,81 @@ def _check_lengths_match(*arrays): | |||
if not all( a.shape == ref for a in arrays): | |||
raise ValueError("Input arrays must all be same shape" | |||
"Got {0}".format([a.shape for a in arrays])) | |||
|
|||
## NOT COMPLETE - NEED REFINEMENT | |||
def distance(atom1,atom2,box=None): |
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.
The call signature should be
distance(a, b, box=None)
where a
and b
are coordinates (numpy arrays of shape (3,)
).
No functions in MDAnalysis.lib
will make explicit reference to atoms or other "core data structures". Look at distance_array()
.
package/MDAnalysis/lib/distances.py
Outdated
name1 = "bynum" + " " + str(atom1) # concatenate string for first selection | ||
name2 = "bynum" + " " + str(atom2) # concatenate string for the second selection | ||
|
||
selection1 = u.select_atoms(name1) # select from universe |
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.
YOu don't need any selections here. Work with raw coordinates.
package/MDAnalysis/lib/distances.py
Outdated
if abs(selection1_selection2_array[i][2]) > u.dimensions[5]: | ||
# Z axis minimum image - follows the LAMMPS convention | ||
if selection1_selection2_array[i][2] < 0.0: | ||
selection1_selection2_array[i][2] += u.dimensions[5] |
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.
If you're using numpy arrays, use numpy array operations, e.g.
selection1_selection2_array[i, 0:3] += u.dimensions [3:6]
package/MDAnalysis/lib/distances.py
Outdated
box_type = box_check(box) ## Check type of box and store it in box_type variable | ||
|
||
if box_type == 'tri_box': | ||
for i in range(len(selection1_selection2_array)): |
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 all a bit complicated. However, implement your tests and then see if your solution works. Once you have one solution it can be improved. But tests are important early on.
package/MDAnalysis/lib/distances.py
Outdated
|
||
return separation | ||
|
||
|
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.
Implement tests!!!!
@Shtkddud123 , if you want to get in a PR for GSoC then I recommend you're not doing this one (this will take longer!) but something very easy such as #1246 or look at #597 (and just write a test that tests raising of an exception that is not being tested yer – the issue #597 has more details). |
Dear Dr Beckstein,
I see. I apologise for the fairly rough code - I was aware of that, but I
think I rushed it to try to make it to April 3rd. I'm still invested in it,
so I'll get back to it with your suggestions.
For the meantime, I'll try to resolve one of the issues you suggested.
Thanks
Sang
…On Fri, Mar 31, 2017 at 9:44 AM, Oliver Beckstein ***@***.***> wrote:
@Shtkddud123 <https://github.com/Shtkddud123> , if you want to get in a
PR for GSoC then I recommend you're not doing this one (this will take
longer!) but something very easy such as #1246
<#1246> or look at #597
<#597> (and just write a
test that tests raising of an exception that is not being tested yer – the
issue #597 <#597> has more
details).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1275 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEg_lKv9zNZfzcyiYAXAZ11IJRpEzEGuks5rrLzWgaJpZM4MuvMw>
.
|
@Shtkddud123 are you interested in continuing this PR or can I close it for the time being? |
Dear Dr Beckstein,
Sorry for the lack of notice. I will be doing it in the next week or so -
sorry, personal situations have got in the way, but I am still committed.
Thank you.
Yours Sincerely
Sang
…On Mon, May 15, 2017 at 9:46 PM, Oliver Beckstein ***@***.***> wrote:
@Shtkddud123 <https://github.com/shtkddud123> are you interested in
continuing this PR or can I close it for the time being?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1275 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEg_lJPkAKKt11fWDv1Zj4lMKj1rXVhmks5r6LmtgaJpZM4MuvMw>
.
|
Ok, just checking.
Btw no need for formal address on GitHub ---- just @orbeckst
… Am May 15, 2017 um 15:12 schrieb Sang Young Noh ***@***.***>:
Dear Dr Beckstein,
Sorry for the lack of notice. I will be doing it in the next week or so -
sorry, personal situations have got in the way, but I am still committed.
Thank you.
Yours Sincerely
Sang
On Mon, May 15, 2017 at 9:46 PM, Oliver Beckstein ***@***.***>
wrote:
> @Shtkddud123 <https://github.com/shtkddud123> are you interested in
> continuing this PR or can I close it for the time being?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1275 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AEg_lJPkAKKt11fWDv1Zj4lMKj1rXVhmks5r6LmtgaJpZM4MuvMw>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Hi @Shtkddud123, thanks for your interest in contributing. There hasn't been much more activity recently and there isn't code in the PR yet that relates to distances and it shows "unknown repository" as the source. Therefore I am going to close this PR. Please submit a new PR if you find the time to work on this problem again. Hope to see you back here! |
Fixes #1262
Changes made in this Pull Request:
PR Checklist