-
Notifications
You must be signed in to change notification settings - Fork 70
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
Molecule Measurements #27
Conversation
""" | ||
|
||
tmp = np.atleast_2d(points) | ||
return np.sqrt(np.einsum("ij,ij->i", tmp, tmp)) |
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.
not duplicating
QCElemental/qcelemental/util/misc.py
Lines 9 to 18 in 81c65d8
def distance_matrix(a, b): | |
"""Euclidean distance matrix between rows of arrays `a` and `b`. Equivalent to | |
`scipy.spatial.distance.cdist(a, b, 'euclidean')`. Returns a.shape[0] x b.shape[0] array. | |
""" | |
assert a.shape[1] == b.shape[1], """Inner dimensions do not match""" | |
distm = np.zeros([a.shape[0], b.shape[0]]) | |
for i in range(a.shape[0]): | |
distm[i] = np.linalg.norm(a[i] - b, axis=1) | |
return distm |
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.
No, this is just a fast norm equivalent to np.linalg.norm(arr, axis=1)
. Somewhat meaningless, but something I often do.
qcelemental/util/misc.py
Outdated
|
||
def measure_coordinates(coordinates, measurements, degrees=False): | ||
""" | ||
Measures a geometry array based on indices provided, automatically detects distance, angle, |
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.
"0-based indices"
qcelemental/util/misc.py
Outdated
points3 : np.ndarray | ||
The third list of points, can be 1D or 2D | ||
degrees : bool, options | ||
Returns the angle in degress rather than radians if True |
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.
"degrees" (ditto in dihedral)
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.
Other than @loriab's remarks, I think this is pretty slick.
@@ -228,6 +228,13 @@ def json(self, *args, **kwargs): | |||
|
|||
### Non-Pydantic API functions | |||
|
|||
def measure(self, measurements, degrees=True): |
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.
Are degrees really the default people expect for quantum chemistry applications? Just a side thought is all
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.
I think so, happy to take other comments here however,
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.
user-facing is usually degrees, I think. coders would rather convert than deal with confused gen chem students running labs and touting vespr. :-)
Adds several routines for computing distances, angles, and dihedrals within QCElemental. In addition adds a
Molecule.measure
command to check internal values.