From ed1ead7b67f8a48c360ff88fdd65791778d54b88 Mon Sep 17 00:00:00 2001 From: Friedrich Haubensak Date: Wed, 10 Jul 2024 21:19:25 +0200 Subject: [PATCH 1/6] some more regex string fixes --- gromacs/fileformats/mdp.py | 2 +- gromacs/qsub.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gromacs/fileformats/mdp.py b/gromacs/fileformats/mdp.py index 01c93c5e..7e3d6f45 100644 --- a/gromacs/fileformats/mdp.py +++ b/gromacs/fileformats/mdp.py @@ -55,7 +55,7 @@ class MDP(odict, utilities.FileUtils): default_extension = "mdp" logger = logging.getLogger("gromacs.formats.MDP") - COMMENT = re.compile("""\s*;\s*(?P.*)""") # eat initial ws + COMMENT = re.compile(r"""\s*;\s*(?P.*)""") # eat initial ws # see regex in cbook.edit_mdp() PARAMETER = re.compile( r""" diff --git a/gromacs/qsub.py b/gromacs/qsub.py index b1da692d..5b00b772 100644 --- a/gromacs/qsub.py +++ b/gromacs/qsub.py @@ -405,13 +405,13 @@ def write_script(template): template, [ ("^ *DEFFNM=", "(?<==)(.*)", deffnm), - ("^#.*(-J)", "((?<=-J\s))\s*\w+", jobname), + ("^#.*(-J)", r"((?<=-J\s))\s*\w+", jobname), ( "^#.*(-A|account_no)", - "((?<=-A\s)|(?<=account_no\s))\s*\w+", + r"((?<=-A\s)|(?<=account_no\s))\s*\w+", budget, ), - ("^#.*(-t)", "(?<=-t\s)(\d+:\d+:\d+)", walltime), + ("^#.*(-t)", r"(?<=-t\s)(\d+:\d+:\d+)", walltime), ("^ *WALL_HOURS=", "(?<==)(.*)", wall_hours), ("^ *STARTDIR=", "(?<==)(.*)", startdir), ("^ *NPME=", "(?<==)(.*)", npme), @@ -430,15 +430,15 @@ def write_script(template): template, [ ("^ *DEFFNM=", "(?<==)(.*)", deffnm), - ("^#.*(-N|job_name)", "((?<=-N\s)|(?<=job_name\s))\s*\w+", jobname), + ("^#.*(-N|job_name)", r"((?<=-N\s)|(?<=job_name\s))\s*\w+", jobname), ( "^#.*(-A|account_no)", - "((?<=-A\s)|(?<=account_no\s))\s*\w+", + r"((?<=-A\s)|(?<=account_no\s))\s*\w+", budget, ), ( "^#.*(-l walltime|wall_clock_limit)", - "(?<==)(\d+:\d+:\d+)", + r"(?<==)(\d+:\d+:\d+)", walltime, ), ("^ *WALL_HOURS=", "(?<==)(.*)", wall_hours), From 4f6f79fa261208a11c977f061d7823a4bd8eeb26 Mon Sep 17 00:00:00 2001 From: Friedrich Haubensak Date: Wed, 10 Jul 2024 21:21:02 +0200 Subject: [PATCH 2/6] numpy.NAN dropped in numpy-2, use numpy.nan --- gromacs/fileformats/xvg.py | 6 +++--- tests/fileformats/test_xvg.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gromacs/fileformats/xvg.py b/gromacs/fileformats/xvg.py index a2f9c767..fad02a5f 100644 --- a/gromacs/fileformats/xvg.py +++ b/gromacs/fileformats/xvg.py @@ -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 @@ -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 if other is not None: c = numpy.empty_like(b) c[~mask] = other - c[mask] = numpy.NAN + c[mask] = numpy.nan ma_c = numpy.ma.array(c, mask=mask) else: ma_c = None diff --git a/tests/fileformats/test_xvg.py b/tests/fileformats/test_xvg.py index ec2ad17e..d510d372 100644 --- a/tests/fileformats/test_xvg.py +++ b/tests/fileformats/test_xvg.py @@ -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 From 071c1083f8d82ab54889fe51db484e48739f1593 Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Fri, 13 Sep 2024 16:52:27 -0700 Subject: [PATCH 3/6] Update gromacs/qsub.py --- gromacs/qsub.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gromacs/qsub.py b/gromacs/qsub.py index 5b00b772..78972183 100644 --- a/gromacs/qsub.py +++ b/gromacs/qsub.py @@ -430,7 +430,11 @@ def write_script(template): template, [ ("^ *DEFFNM=", "(?<==)(.*)", deffnm), - ("^#.*(-N|job_name)", r"((?<=-N\s)|(?<=job_name\s))\s*\w+", jobname), + ( + "^#.*(-N|job_name)", + r"((?<=-N\s)|(?<=job_name\s))\s*\w+", + jobname, + ), ( "^#.*(-A|account_no)", r"((?<=-A\s)|(?<=account_no\s))\s*\w+", From b2d114a9624d17bc9a5627d7b48fccccba1978e8 Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Fri, 13 Sep 2024 23:56:38 +0000 Subject: [PATCH 4/6] make black happy --- gromacs/qsub.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gromacs/qsub.py b/gromacs/qsub.py index 78972183..7f853a63 100644 --- a/gromacs/qsub.py +++ b/gromacs/qsub.py @@ -431,9 +431,9 @@ def write_script(template): [ ("^ *DEFFNM=", "(?<==)(.*)", deffnm), ( - "^#.*(-N|job_name)", - r"((?<=-N\s)|(?<=job_name\s))\s*\w+", - jobname, + "^#.*(-N|job_name)", + r"((?<=-N\s)|(?<=job_name\s))\s*\w+", + jobname, ), ( "^#.*(-A|account_no)", From e0b3560603232ad10bb70b1317f2737843089863 Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Fri, 13 Sep 2024 23:59:53 +0000 Subject: [PATCH 5/6] add @hsk17 to AUTHORS and CHANGES --- AUTHORS | 5 +++++ CHANGES | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index b9f14057..a30088c2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -68,6 +68,11 @@ year of their first commit. GitHub handle is optional. ---- - Jinzhe Zeng (@njzjz) + +2024 +---- + +- @hsk17 We gratefully acknowledge code fixes contributed by @quantifiedcode-bot from Quantified Code https://www.quantifiedcode.com diff --git a/CHANGES b/CHANGES index bbf6f0bd..c3e58a01 100644 --- a/CHANGES +++ b/CHANGES @@ -3,7 +3,7 @@ ============================== 2024-??-?? 0.9.1 -orbeckst +orbeckst, hsk17 * templates in `config.templates` are now stored as `importlib.resources.abc.Traversable` (PosixPath-like) objects instead of From 51f9addcc1704d5600cb00832a09e6f96652db83 Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Sat, 14 Sep 2024 15:54:25 -0700 Subject: [PATCH 6/6] Update AUTHORS --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index a30088c2..f0cb0b2d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -72,7 +72,7 @@ year of their first commit. GitHub handle is optional. 2024 ---- -- @hsk17 +- Friedrich Haubensak (@hsk17) We gratefully acknowledge code fixes contributed by @quantifiedcode-bot from Quantified Code https://www.quantifiedcode.com