diff --git a/export/fortran/c_to_f.py b/export/fortran/c_to_f.py index afce043cd..f724d14c7 100644 --- a/export/fortran/c_to_f.py +++ b/export/fortran/c_to_f.py @@ -8,10 +8,11 @@ c_to_f.py ''' -import re, sys +import re +import sys def extract_c_struct_fields(c_code, struct_name): - struct_re = re.compile("^\s*typedef\s*struct\s*\{([^\}]*)\}\s*"+struct_name+"\s*;",re.MULTILINE | re.DOTALL) + struct_re = re.compile(r"^\s*typedef\s*struct\s*\{([^\}]*)\}\s*"+struct_name+r"\s*;",re.MULTILINE | re.DOTALL) m = struct_re.search(c_code) if not m: return [] fields = m.group(1).splitlines() @@ -26,7 +27,7 @@ def parse_c_struct_fields(fields): for f in fields: words = f.split() var = words.pop() - m = re.match("(\w*)(?:\[(\w+)\])?", var) + m = re.match(r"(\w*)(?:\[(\w+)\])?", var) name.append(m.group(1)) size.append(m.group(2)) dtype.append(' '.join(words)) @@ -77,4 +78,4 @@ def convert_type_c_to_f(dtype): f_out.write("end type\n") c_in.close() -f_out.close() \ No newline at end of file +f_out.close() diff --git a/export/fortran/make_defs.py b/export/fortran/make_defs.py index 12ecfd176..55032f507 100644 --- a/export/fortran/make_defs.py +++ b/export/fortran/make_defs.py @@ -1,4 +1,5 @@ -import re, sys +import re +import sys f_in = open(sys.argv[1], 'r') f_out = open(sys.argv[2], 'w') for line in f_in: diff --git a/python/setup.py.in b/python/setup.py.in index 8f1b242e6..406f6218b 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,7 +1,8 @@ import setuptools from setuptools import setup, Extension from setuptools.command.build_ext import build_ext -import os, subprocess +import os +import subprocess # sources+tests os.sys.path.append("@PROJECT_SOURCE_DIR@") diff --git a/tests/hartree-fock/hartree-fock++-validate.py b/tests/hartree-fock/hartree-fock++-validate.py index d895a450e..857e8fd13 100644 --- a/tests/hartree-fock/hartree-fock++-validate.py +++ b/tests/hartree-fock/hartree-fock++-validate.py @@ -1,10 +1,13 @@ from __future__ import print_function -import sys, re, math, os +import math +import os +import re +import sys def pat_numbers(n): result = '' for i in range(n): - result += '\s*([+-e\d.]+)' + result += r'\s*([+-e\d.]+)' return result def validate(label, data, refdata, tolerance, textline): @@ -107,21 +110,21 @@ def validate(label, data, refdata, tolerance, textline): Hok = False if LIBINT_ONEBODY_DERIV>1 and LIBINT_ERI_DERIV>1 else True for line in instr: - match1 = re.match('\*\* Hartree-Fock energy =' + pat_numbers(1), line) - match2 = re.match('\*\* edipole =' + pat_numbers(3), line) - match3 = re.match('\*\* equadrupole =' + pat_numbers(6), line) - match4 = re.match('\*\* 1-body forces =' + pat_numbers(9), line) - match5 = re.match('\*\* Pulay forces =' + pat_numbers(9), line) - match6 = re.match('\*\* 2-body forces =' + pat_numbers(9), line) - match7 = re.match('\*\* nuclear repulsion forces =' + pat_numbers(9), line) - match8 = re.match('\*\* Hartree-Fock forces =' + pat_numbers(9), line) - match9 = re.match('\*\* 1-body hessian =' + pat_numbers(45), line) - match10 = re.match('\*\* Pulay hessian =' + pat_numbers(45), line) - match11 = re.match('\*\* 2-body hessian =' + pat_numbers(45), line) - match12 = re.match('\*\* nuclear repulsion hessian =' + pat_numbers(45), line) - match13 = re.match('\*\* Hartree-Fock hessian =' + pat_numbers(45), line) - match14 = re.match('\*\* sph edipole =' + pat_numbers(3), line) - match15 = re.match('\*\* sph equadrupole =' + pat_numbers(5), line) + match1 = re.match(r'\*\* Hartree-Fock energy =' + pat_numbers(1), line) + match2 = re.match(r'\*\* edipole =' + pat_numbers(3), line) + match3 = re.match(r'\*\* equadrupole =' + pat_numbers(6), line) + match4 = re.match(r'\*\* 1-body forces =' + pat_numbers(9), line) + match5 = re.match(r'\*\* Pulay forces =' + pat_numbers(9), line) + match6 = re.match(r'\*\* 2-body forces =' + pat_numbers(9), line) + match7 = re.match(r'\*\* nuclear repulsion forces =' + pat_numbers(9), line) + match8 = re.match(r'\*\* Hartree-Fock forces =' + pat_numbers(9), line) + match9 = re.match(r'\*\* 1-body hessian =' + pat_numbers(45), line) + match10 = re.match(r'\*\* Pulay hessian =' + pat_numbers(45), line) + match11 = re.match(r'\*\* 2-body hessian =' + pat_numbers(45), line) + match12 = re.match(r'\*\* nuclear repulsion hessian =' + pat_numbers(45), line) + match13 = re.match(r'\*\* Hartree-Fock hessian =' + pat_numbers(45), line) + match14 = re.match(r'\*\* sph edipole =' + pat_numbers(3), line) + match15 = re.match(r'\*\* sph equadrupole =' + pat_numbers(5), line) if match1: eok = validate("HF energy", match1.groups(), eref, etol, line) elif match2: diff --git a/tests/hartree-fock/hartree-fock-validate.py b/tests/hartree-fock/hartree-fock-validate.py index d771fb6b8..c89c9513d 100644 --- a/tests/hartree-fock/hartree-fock-validate.py +++ b/tests/hartree-fock/hartree-fock-validate.py @@ -1,5 +1,7 @@ from __future__ import print_function -import sys, re, math +import math +import re +import sys # first arg is the input file, if missing read sys.stdin try: @@ -14,7 +16,7 @@ returncode = 1 for line in instr: print(line,end="") - x = re.match('\*\* Hartree-Fock energy =\s*([-\d.]+)', line) + x = re.match(r'\*\* Hartree-Fock energy =\s*([-\d.]+)', line) if x: efound_str = x.group(1) if (math.fabs(eref - float(efound_str)) < tol): @@ -24,4 +26,4 @@ if len(sys.argv) > 1: instr.close() -sys.exit(returncode) \ No newline at end of file +sys.exit(returncode)