Skip to content

Commit

Permalink
Fix several DeprecationWarning: invalid escape sequence (pytorch#15733)
Browse files Browse the repository at this point in the history
Summary:
Hello,

This is a little patch to fix `DeprecationWarning: invalid escape sequence`.
Pull Request resolved: pytorch#15733

Differential Revision: D13587291

Pulled By: soumith

fbshipit-source-id: ce68db2de92ca7eaa42f78ca5ae6fbc1d4d90e05
  • Loading branch information
BoboTiG authored and facebook-github-bot committed Jan 5, 2019
1 parent 2fb2d08 commit 04f5605
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion caffe2/contrib/cuda-convnet2/python_util/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run(self):
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)
Expand Down
2 changes: 1 addition & 1 deletion caffe2/contrib/cuda-convnet2/python_util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions caffe2/python/docs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ 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
),
('`(.+?)`',
lambda m, f: f.addCode(m.group(1), True)
),
# 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)
),
]
Expand Down
2 changes: 1 addition & 1 deletion scripts/diagnose_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions tools/amd_build/pyHIPIFY/hipify_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 04f5605

Please sign in to comment.