Skip to content

Commit

Permalink
replaced numpy.NAN,INF with numpy.nan,inf
Browse files Browse the repository at this point in the history
fix #290
  • Loading branch information
orbeckst committed Sep 13, 2024
1 parent a5bcc8a commit ab88637
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ orbeckst
(#282)
* fixed reporting of failures of GromacsCommand and DeprecationWarnings for use
of \s in regular expression strings (#285)
* fixed use of outdated numpy.NAN | INF by using nan | inf (#290)


2024-06-15 0.9.0
Expand Down
6 changes: 3 additions & 3 deletions gromacs/fileformats/xvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
class XVG(utilities.FileUtils):
"""Class that represents the numerical data in a grace xvg file.
All data must be numerical. :const:`NAN` and :const:`INF` values are
All data must be numerical. :const:`nan` and :const:`inf` values are
supported via python's :func:`float` builtin function.
The :attr:`~XVG.array` attribute can be used to access the the
Expand Down Expand Up @@ -1326,12 +1326,12 @@ def break_array(a, threshold=numpy.pi, other=None):
mask = numpy.zeros_like(b, dtype=bool)
mask[b_breaks] = True
b[~mask] = a
b[mask] = numpy.NAN
b[mask] = numpy.nan

Check warning on line 1329 in gromacs/fileformats/xvg.py

View check run for this annotation

Codecov / codecov/patch

gromacs/fileformats/xvg.py#L1329

Added line #L1329 was not covered by tests

if other is not None:
c = numpy.empty_like(b)
c[~mask] = other
c[mask] = numpy.NAN
c[mask] = numpy.nan

Check warning on line 1334 in gromacs/fileformats/xvg.py

View check run for this annotation

Codecov / codecov/patch

gromacs/fileformats/xvg.py#L1334

Added line #L1334 was not covered by tests
ma_c = numpy.ma.array(c, mask=mask)
else:
ma_c = None
Expand Down
2 changes: 1 addition & 1 deletion tests/fileformats/test_xvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_plot_coarsend(self, xvg):

def test_break_array():
angles = np.pi * np.array([-1.9, -1, -1, -0.5, 0, 0.9, 1.5, 2, -2, -1.4])
expected = np.pi * np.array([-1.9, -1, -1, -0.5, 0, 0.9, 1.5, 2, np.NAN, -2, -1.4])
expected = np.pi * np.array([-1.9, -1, -1, -0.5, 0, 0.9, 1.5, 2, np.nan, -2, -1.4])
other = np.ones_like(angles)
ma, mother = gromacs.fileformats.xvg.break_array(
angles, threshold=np.pi, other=other
Expand Down

0 comments on commit ab88637

Please sign in to comment.