diff --git a/cmake/FindPythonModule.cmake b/cmake/FindPythonModule.cmake index 82218f509286489f208111e6e66120972e746904..106d82d2c6aebe8d64fb27c6e162deb521418c4b 100644 --- a/cmake/FindPythonModule.cmake +++ b/cmake/FindPythonModule.cmake @@ -11,7 +11,7 @@ function(find_python_module module) # A module's location is usually a directory, but for binary modules # it's a .so file. execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))" + "import re, ${module}; print(re.compile(r'/__init__.py.*').sub('',${module}.__file__))" RESULT_VARIABLE _${module}_status OUTPUT_VARIABLE _${module}_location ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/cmake/FindSphinxModule.cmake b/cmake/FindSphinxModule.cmake index bf2a99fd2b54c59c695d541d5a99892f67ca7d6d..13c5b1b0deb315d1595ca429f613b8584208d9dd 100644 --- a/cmake/FindSphinxModule.cmake +++ b/cmake/FindSphinxModule.cmake @@ -20,7 +20,7 @@ function(find_sphinx_module parent module) set(${module}_FIND_REQUIRED TRUE) endif() execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "import re; from ${parent} import ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))" + "import re; from ${parent} import ${module}; print(re.compile(r'/__init__.py.*').sub('',${module}.__file__))" RESULT_VARIABLE _${module}_status OUTPUT_VARIABLE _${module}_location ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/cmake/sort_f90.py b/cmake/sort_f90.py index bd36c0807725f453376dadf19afa8391e90fc4af..a5f8cd45acfdd6d26431efed6c8d4236ba7c4115 100644 --- a/cmake/sort_f90.py +++ b/cmake/sort_f90.py @@ -92,7 +92,7 @@ Here is a breakdown of the regex: (modulename_regex) : match the module name that is being USE'd, see above. """ use_regex = \ - "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(%s)" %\ + r"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(%s)" %\ modulename @@ -120,7 +120,7 @@ Here is a breakdown of the regex: that make up the defined module name and save it in a group """ -def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(%s)""" % modulename +def_regex = r"""(?i)^\s*MODULE\s+(?!PROCEDURE)(%s)""" % modulename """ @@ -179,7 +179,7 @@ Here is a breakdown of the regex: (as allowed by the F2003 standard) """ include_regex = \ - """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" + r"""(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" """ diff --git a/hysop/__init__.py.in b/hysop/__init__.py.in index 45a998546c27344c8df1a92a0befea7061d86ac7..73a195c6f53ff5c372bdbca45f90181eff039988 100644 --- a/hysop/__init__.py.in +++ b/hysop/__init__.py.in @@ -86,6 +86,16 @@ __FFTW_PLANNER_TIMELIMIT__ = int(get_env('FFTW_PLANNER_TIMELIMIT', -1)) __DEFAULT_PLATFORM_ID__ = int(get_env('DEFAULT_PLATFORM_ID', @OPENCL_DEFAULT_OPENCL_PLATFORM_ID@)) __DEFAULT_DEVICE_ID__ = int(get_env('DEFAULT_DEVICE_ID', @OPENCL_DEFAULT_OPENCL_DEVICE_ID@)) + +if __TRACE_WARNINGS__: + warnings.simplefilter('always') + try: + import pyopencl + warnings.filterwarnings(action='module', category=pyopencl.CompilerWarning) + except ImportError: + pass + + if __MPI_ENABLED__: from hysop.core.mpi import MPI, main_rank, main_size, \ host_rank, interhost_size, \ diff --git a/hysop/backend/device/codegen/base/struct_codegen.py b/hysop/backend/device/codegen/base/struct_codegen.py index 3a218a9def44361fad25192800da3e528ddcfcd0..fb4b913a04bac5b55414e85880a3b6e7458d167e 100644 --- a/hysop/backend/device/codegen/base/struct_codegen.py +++ b/hysop/backend/device/codegen/base/struct_codegen.py @@ -40,7 +40,7 @@ class StructCodeGenerator(OpenClCodeGenerator): return cdecl def gencode(self, comments, ctype_overrides): - struct_vars = re.compile('\s+((?:struct\s+)?\w+)\s+((?:\s*\**(?:\w+)(?:\[\d+\])*[,;])+)') + struct_vars = re.compile(r'\s+((?:struct\s+)?\w+)\s+((?:\s*\**(?:\w+)(?:\[\d+\])*[,;])+)') lines = self.c_decl().split('\n') with self._struct_(name=self.name,typedef=self.typedef): diff --git a/hysop/backend/device/codegen/base/union_codegen.py b/hysop/backend/device/codegen/base/union_codegen.py index c574b2c5eac4126b2ec3ee9c511ee02b5e40ccb1..7f50762a3c903cbfcbec36acd7754823765ddb1a 100644 --- a/hysop/backend/device/codegen/base/union_codegen.py +++ b/hysop/backend/device/codegen/base/union_codegen.py @@ -15,9 +15,9 @@ class UnionCodeGenerator(OpenClCodeGenerator): typedef=None,comments=None, ctype_overrides=None, custom_types={}): - + super(UnionCodeGenerator,self).__init__(name=name,typegen=typegen) - + self.typedef = typedef self.dtype = np.dtype(dtype) self.ctype = self.typedef if (self.typedef is not None) else 'union {}'.format(self.name) @@ -26,20 +26,20 @@ class UnionCodeGenerator(OpenClCodeGenerator): register_ctype_dtype(self.ctype,self.dtype) self.gencode(comments, ctype_overrides) - + def c_decl(self): assert (self.context is not None) dtype,cdecl = cl.tools.match_dtype_to_c_struct( \ self.device,self.ctype.replace('union',''),self.dtype,context=self.context) return cdecl - + def fields(self): return self.dtype.fields def gencode(self, comments, ctype_overrides): - union_vars = re.compile('\s+((?:struct\s+)?\w+)\s+((?:\s*\**(?:\w+)(?:\[\d+\])*[,;])+)') + union_vars = re.compile(r'\s+((?:struct\s+)?\w+)\s+((?:\s*\**(?:\w+)(?:\[\d+\])*[,;])+)') lines = self.c_decl().split('\n') - + with self._union_(name=self.name,typedef=self.typedef): with self._var_block_() as vb: i=0 @@ -73,5 +73,5 @@ if __name__ == '__main__': typegen=_test_typegen()) scg.edit() scg.test_compile() - + diff --git a/hysop/backend/device/opencl/opencl_array_backend.py b/hysop/backend/device/opencl/opencl_array_backend.py index aafa8cbff584ca30dc2755592a7da0173236d8a2..58a90acc1705db6221b2c6c1b301ae5f0f46f151 100644 --- a/hysop/backend/device/opencl/opencl_array_backend.py +++ b/hysop/backend/device/opencl/opencl_array_backend.py @@ -616,7 +616,7 @@ class OpenClArrayBackend(ArrayBackend): if (arguments[i] is None): arguments[i] = argument if is_output: - affectation = '{}\[i\]\s*=\s*([\s\S]*?)\s*$'.format(argname) + affectation = r'{}\[i\]\s*=\s*([\s\S]*?)\s*$'.format(argname) affectation = re.compile(affectation) is_cast = (argcast[i] is not None) for (k,v) in filter_expr.items(): diff --git a/hysop/backend/device/opencl/opencl_device.py b/hysop/backend/device/opencl/opencl_device.py index e655427ea8cc846d177678ae745bd3f53849f9ed..682baca1a3e7ccc1259124241975f94f0e98ddd7 100644 --- a/hysop/backend/device/opencl/opencl_device.py +++ b/hysop/backend/device/opencl/opencl_device.py @@ -186,7 +186,7 @@ class OpenClDevice(LogicalDevice): def _extract_cl_version(self, device_handle): version = device_handle.version - regexp = re.compile('OpenCL ([0-9]+)\.([0-9]+)') + regexp = re.compile(r'OpenCL ([0-9]+)\.([0-9]+)') match = re.match(regexp, version) assert match, 'Could not match opencl version from \'{}\'.'.format(version) (major, minor) = int(match.group(1)), int(match.group(2)) diff --git a/hysop/backend/device/opencl/opencl_env.py b/hysop/backend/device/opencl/opencl_env.py index 31328da03cf8a0d2c54e54ccb3f44751bbdfdf64..0b679eac3aeb4c2164d3c9aae5dfc30cb7f1ea96 100644 --- a/hysop/backend/device/opencl/opencl_env.py +++ b/hysop/backend/device/opencl/opencl_env.py @@ -313,7 +313,7 @@ device.opencl_c_version, bytes2str(device.global_mem_size)) def _parse_opencl_version(self): assert (self.device is not None) sversion = self.device.version.strip() - _regexp='OpenCL\s+(\d)\.(\d)' + _regexp=r'OpenCL\s+(\d)\.(\d)' regexp=re.compile(_regexp) match=re.match(regexp,sversion) if not match: diff --git a/hysop/backend/device/opencl/opencl_tools.py b/hysop/backend/device/opencl/opencl_tools.py index 84032733d8f5c30331d66995808ad3e3a13e9a48..2d0259e5f145db9208299d49bf65ad8f8feb22ce 100644 --- a/hysop/backend/device/opencl/opencl_tools.py +++ b/hysop/backend/device/opencl/opencl_tools.py @@ -439,8 +439,8 @@ def parse_opencl_file(f, n=8, nb_remesh_components=1): src = "" # replacement for floatN elements vec_floatn = re.compile(r'\(float__N__\)\(') - vec_nn = re.compile('__NN__') - vec_n = re.compile('__N__') + vec_nn = re.compile(r'__NN__') + vec_n = re.compile(r'__N__') for l in f.readlines(): # Expand floatN items if vec_floatn.search(l) and vec_nn.search(l) and \ diff --git a/hysop/backend/hardware/pci.py b/hysop/backend/hardware/pci.py index f423f3a80946d330bd4a660c93fdf4fb15cab72f..28de9168e4143cc000b9746392e75be7a406313d 100644 --- a/hysop/backend/hardware/pci.py +++ b/hysop/backend/hardware/pci.py @@ -135,8 +135,8 @@ class PciDevice(TopologyObject): def _post_init(self): pci_type = self.pci_type() - regexp = '([a-f0-9]{4})\s+\[([a-f0-9]{4}):([a-f0-9]{4})\]\s+' - regexp += '\[([a-f0-9]{4}):([a-f0-9]{4})\]\s+([a-f0-9]{2})' + regexp = r'([a-f0-9]{4})\s+\[([a-f0-9]{4}):([a-f0-9]{4})\]\s+' + regexp += r'\[([a-f0-9]{4}):([a-f0-9]{4})\]\s+([a-f0-9]{2})' regexp = re.compile(regexp) match = re.match(regexp, pci_type) if not match: diff --git a/hysop/backend/hardware/pci_ids.py b/hysop/backend/hardware/pci_ids.py index 8de2a7cb544f7aa4c324275ddd7a4958013258bb..a3ebdbd2b1e0551c1a73658f698068757e9d17e8 100644 --- a/hysop/backend/hardware/pci_ids.py +++ b/hysop/backend/hardware/pci_ids.py @@ -14,7 +14,7 @@ def _fmt_name(name): return name.strip().lower() class PciVendor(object): - _regexp = re.compile('([0-9a-f]{4})\s+(.*)') + _regexp = re.compile(r'([0-9a-f]{4})\s+(.*)') def __init__(self, vendor): """ @@ -90,7 +90,7 @@ class PciVendor(object): return self.name class PciDevice(object): - _regexp = re.compile('([0-9a-f]{4})\s+(.*)') + _regexp = re.compile(r'([0-9a-f]{4})\s+(.*)') def __init__(self, device, vendor): device = device.strip() @@ -127,7 +127,7 @@ class PciDevice(object): return self.name class PciSubDevice(object): - _regexp = re.compile('([0-9a-f]{4})\s+([0-9a-f]{4})\s+(.*)') + _regexp = re.compile(r'([0-9a-f]{4})\s+([0-9a-f]{4})\s+(.*)') def __init__(self, subdevice, device, vendor): subdevice = subdevice.strip() match = re.match(self._regexp, subdevice) @@ -148,7 +148,7 @@ class PciSubDevice(object): return self.name class PciDeviceClass(object): - _regexp = re.compile('C\s+([0-9a-f]{2})\s+(.*)') + _regexp = re.compile(r'C\s+([0-9a-f]{2})\s+(.*)') def __init__(self, device_class): device_class = device_class.strip() @@ -181,7 +181,7 @@ class PciDeviceClass(object): return self.name class PciDeviceSubClass(object): - _regexp = re.compile('([0-9a-f]{2})\s+(.*)') + _regexp = re.compile(r'([0-9a-f]{2})\s+(.*)') def __init__(self, device_subclass, device_class): device_subclass = device_subclass.strip() @@ -210,7 +210,7 @@ class PciDeviceSubClass(object): return '{} ({})'.format(self.name, self.device_class.name) class PciProgrammingInterface(object): - _regexp = re.compile('([0-9a-f]{2})\s+(.*)') + _regexp = re.compile(r'([0-9a-f]{2})\s+(.*)') def __init__(self, interface, device_subclass, device_class): interface = interface.strip() diff --git a/hysop/numerics/fft/_mkl_fft.py b/hysop/numerics/fft/_mkl_fft.py index 1d1758369487cb39dfbc2d9acdc536ef76f1968d..3e7cc39abc001b6d72832087d222088959e9366c 100644 --- a/hysop/numerics/fft/_mkl_fft.py +++ b/hysop/numerics/fft/_mkl_fft.py @@ -1,4 +1,4 @@ -""" +r""" FFT interface for fast Fourier Transforms using Intel MKL (numpy interface). :class:`~hysop.numerics.MklFFT` :class:`~hysop.numerics.MklFFTPlan` diff --git a/hysop/tools/plotDrag.py b/hysop/tools/plotDrag.py index 4d39e893c4bbaa948f11823fe757d51248e42fb6..7f1841446096d28963cf1c8f69fe62d41a1102f0 100644 --- a/hysop/tools/plotDrag.py +++ b/hysop/tools/plotDrag.py @@ -32,8 +32,8 @@ def _ft_read(fileobj, commentchar='#'): return None fileobj.seek(location) - blankline = re.compile('\n\s*\n', re.M) - commentline = re.compile('^%s[^\n]*\n' % commentchar, re.M) + blankline = re.compile(r'\n\s*\n', re.M) + commentline = re.compile(r'^%s[^\n]*\n' % commentchar, re.M) filestr = fileobj.read() # remove lines after a blank line m = re.search(blankline, filestr) diff --git a/hysop/tools/profiling.py b/hysop/tools/profiling.py index 4b1857c3b5e36e78278d44b7232f40863d36b080..2460d82c6b8075f8952278a23126c4929d0f0167 100644 --- a/hysop/tools/profiling.py +++ b/hysop/tools/profiling.py @@ -280,7 +280,7 @@ else: hysop.reset() memStat, memStatPieChart = launch_meliae_profiling() # Create results string -regexp = re.compile('(.*\d{4})\s+(?:(?:/\w+)+/)?(\w+\.pstat)') +regexp = re.compile(r'(.*\d{4})\s+(?:(?:/\w+)+/)?(\w+\.pstat)') files = [] for file_ in p.files: res = regexp.match(file_) diff --git a/setup.py.in b/setup.py.in index 512876d174c00044be8f0b063bdd13759adaff35..6edf1a4090d7b5d19ecb2e28487fb9bd1fcaf702 100644 --- a/setup.py.in +++ b/setup.py.in @@ -50,7 +50,7 @@ def parseCMakeDefines(var): # regex to match compiler defines like -DMACRO_NAME or # -DMACRO_NAME = MACRO_VALUE - p = re.compile('\s*(?:-D)?\s*(\w+)(?:\s*=\s*(\w+))?\s*') + p = re.compile(r'\s*(?:-D)?\s*(\w+)(?:\s*=\s*(\w+))?\s*') res = list() for d in defines: