Fix several DeprecationWarning: invalid escape sequence (#15733)

Summary:
Hello,

This is a little patch to fix `DeprecationWarning: invalid escape sequence`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15733

Differential Revision: D13587291

Pulled By: soumith

fbshipit-source-id: ce68db2de92ca7eaa42f78ca5ae6fbc1d4d90e05
This commit is contained in:
Mickaël Schoentgen
2019-01-05 08:51:14 -08:00
committed by Facebook Github Bot
parent 2fb2d080d3
commit 04f5605ba1
5 changed files with 10 additions and 10 deletions

View File

@ -29,7 +29,7 @@ class DataLoaderThread(Thread):
self.tgt += [unpickle(self.path)]
class DataProvider:
BATCH_REGEX = re.compile('^data_batch_(\d+)(\.\d+)?$')
BATCH_REGEX = re.compile(r'^data_batch_(\d+)(\.\d+)?$')
def __init__(self, data_dir, batch_range=None, init_epoch=1, init_batchnum=None, dp_params={}, test=False):
if batch_range == None:
batch_range = DataProvider.get_batch_nums(data_dir)

View File

@ -48,7 +48,7 @@ def unpickle(filename):
return dict
def is_intel_machine():
VENDOR_ID_REGEX = re.compile('^vendor_id\s+: (\S+)')
VENDOR_ID_REGEX = re.compile(r'^vendor_id\s+: (\S+)')
f = open('/proc/cpuinfo')
for line in f:
m = VENDOR_ID_REGEX.match(line)

View File

@ -19,10 +19,10 @@ class Parser(object):
('```(.+?)```',
lambda m, f: f.addCode(m.group(1))
),
('((( {2})+)(\S.*)(\n\s*\n|\n))+',
(r'((( {2})+)(\S.*)(\n\s*\n|\n))+',
lambda m, f: f.addCode(m.group(0))
),
('([^\.])\n',
(r'([^\.])\n',
lambda m, f: f.addRaw('{c} '.format(c=m.group(1))) or True
),
('`(.+?)`',
@ -30,13 +30,13 @@ class Parser(object):
),
# Make links clickable
('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]'
'|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
r'|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
lambda m, f: f.addLink(m.group(0), m.group(0))
),
('\*\*(.+?)\*\*',
(r'\*\*(.+?)\*\*',
lambda m, f: f.addEmphasis(m.group(1), 2)
),
('\*(.+?)\*',
(r'\*(.+?)\*',
lambda m, f: f.addEmphasis(m.group(1), 1)
),
]

View File

@ -50,7 +50,7 @@ else:
print('DEBUG: err: ' + err)
native_protobuf_installed = False
else:
tmp = re.search('\d\.\d\.\d', out)
tmp = re.search(r'\d\.\d\.\d', out)
if tmp:
native_version = tmp.group(0)
native_protobuf_installed = True

View File

@ -613,7 +613,7 @@ def disable_function(input_string, function, replace_style):
else:
# Automatically detect signature.
the_match = re.search(r"(((.*) (\*)?)({0})(\([^{{)]*\)))\s*{{".format(
function.replace("(", "\(").replace(")", "\)")), input_string)
function.replace("(", r"\(").replace(")", r"\)")), input_string)
if the_match is None:
return input_string
@ -1177,7 +1177,7 @@ def extract_arguments(start, string):
return arguments
RE_HIP_LAUNCH_KERNEL_GGL = re.compile("hipLaunchKernelGGL\(")
RE_HIP_LAUNCH_KERNEL_GGL = re.compile(r"hipLaunchKernelGGL\(")
# Add static_cast to ensure that the type of kernel arguments matches that in the corresponding kernel definition