Skip to content

Commit

Permalink
Fix DeprecationWarning by using np.arctan2 for element-wise array ope…
Browse files Browse the repository at this point in the history
…rations in phase_ang calculation (NumPy 1.25+ compatibility)
  • Loading branch information
laksh-krishna-sharma committed Oct 11, 2024
1 parent 1bf58cc commit ace3f70
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions package/MDAnalysis/analysis/nuclinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def phase_cp(universe, seg, i):
+ (r3_d * cos(4 * pi * 2.0 / 5.0)) + (r4_d * cos(4 * pi * 3.0 / 5.0))
+ (r5_d * cos(4 * pi * 4.0 / 5.0))) * sqrt(2.0 / 5.0)

phase_ang = (atan2(D, C) + (pi / 2.)) * 180. / pi
phase_ang = (np.arctan2(D, C) + (np.pi / 2.)) * 180. / np.pi # np.arctan2(D, C) will now compute the arctangent element-wise for arrays D and C, ensuring compatibility with future NumPy versions.
return phase_ang % 360


Expand Down Expand Up @@ -368,7 +368,7 @@ def phase_as(universe, seg, i):
+ (data4 * cos(2 * 2 * pi * (4 - 1.) / 5.))
+ (data5 * cos(2 * 2 * pi * (5 - 1.) / 5.))) * 2. / 5.

phase_ang = atan2(B, A) * 180. / pi
phase_ang = (np.arctan2(D, C) + (np.pi / 2.)) * 180. / np.pi
return phase_ang % 360


Expand Down Expand Up @@ -482,7 +482,7 @@ def tors_alpha(universe, seg, i):


def tors_beta(universe, seg, i):
"""beta backbone dihedral
"""beta backbone dihedral
The dihedral is computed based on position atoms for resid `i`.
Expand All @@ -500,7 +500,6 @@ def tors_beta(universe, seg, i):
beta : float
torsion angle in degrees
.. versionadded:: 0.7.6
"""
b = universe.select_atoms(" atom {0!s} {1!s} P ".format(seg, i),
Expand Down

0 comments on commit ace3f70

Please sign in to comment.