Skip to content

Resolve deprecation warnings of regex library #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions kernel_tuner/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def prepare_list_of_files(
The files beyond the first are considered additional files that may also contain tunable parameters

For each file beyond the first this function creates a temporary file with
preprocessors statements inserted. Occurences of the original filenames in the
preprocessors statements inserted. Occurrences of the original filenames in the
first file are replaced with their temporary counterparts.

:param kernel_name: A string specifying the kernel name.
Expand Down Expand Up @@ -180,7 +180,7 @@ def prepare_list_of_files(
temp_file = util.get_temp_filename(suffix="." + f.split(".")[-1])
temp_files[f] = temp_file
util.write_file(temp_file, ks)
# replace occurences of the additional file's name in the first kernel_string with the name of the temp file
# replace occurrences of the additional file's name in the first kernel_string with the name of the temp file
kernel_string = kernel_string.replace(f, temp_file)

return name, kernel_string, temp_files
Expand Down Expand Up @@ -511,7 +511,7 @@ def check_kernel_output(
# run the kernel
check = self.run_kernel(func, gpu_args, instance)
if not check:
return # runtime failure occured that should be ignored, skip correctness check
return # runtime failure occurred that should be ignored, skip correctness check

# retrieve gpu results to host memory
result_host = []
Expand Down Expand Up @@ -595,7 +595,7 @@ def compile_and_benchmark(self, kernel_source, gpu_args, params, kernel_options,
if kernel_options.texmem_args is not None:
self.dev.copy_texture_memory_args(kernel_options.texmem_args)

# stop compilation stopwatch and convert to miliseconds
# stop compilation stopwatch and convert to milliseconds
last_compilation_time = 1000 * (time.perf_counter() - start_compilation)

# test kernel for correctness
Expand Down Expand Up @@ -628,7 +628,7 @@ def compile_and_benchmark(self, kernel_source, gpu_args, params, kernel_options,
)
raise e

# clean up any temporary files, if no error occured
# clean up any temporary files, if no error occurred
instance.delete_temp_files()

result["compile_time"] = last_compilation_time or 0
Expand Down Expand Up @@ -905,7 +905,7 @@ def _flatten(a):
+ " detected during correctness check"
)
print(
"this error occured when checking value of the %oth kernel argument"
"this error occurred when checking value of the %oth kernel argument"
% (i,)
)
print(
Expand Down Expand Up @@ -934,7 +934,7 @@ def split_argument_list(argument_list):
match = re.match(regex, arg, re.S)
if not match:
raise ValueError("error parsing templated kernel argument list")
type_list.append(re.sub(r"\s+", " ", match.group(1).strip(), re.S))
type_list.append(re.sub(r"\s+", " ", match.group(1).strip(), flags=re.S))
name_list.append(match.group(2).strip())
return type_list, name_list

Expand All @@ -956,7 +956,7 @@ def replace_typename_token(matchobj):
# if the templated typename occurs as a token in the string, meaning that it is enclosed in
# beginning of string or whitespace, and end of string, whitespace or star
regex = r"(^|\s+)(" + k + r")($|\s+|\*)"
sub = re.sub(regex, replace_typename_token, arg_type, re.S)
sub = re.sub(regex, replace_typename_token, arg_type, flags=re.S)
type_list[i] = sub


Expand Down