Skip to content

Commit 630ecb0

Browse files
committed
Made file read mode have explicit encodings to have consistent behaviour across operating systems
1 parent 2eb4e5f commit 630ecb0

File tree

7 files changed

+9
-7
lines changed

7 files changed

+9
-7
lines changed

cached_data_used/cachefiles/ktt_values_to_kerneltuner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
# print(f"Replacing {kt_old_objective_value} with {kt_new_objective_value}")
9696

9797
# load the individual lines of the file
98-
with kerneltuner_cachefile.open(mode="r") as fp:
98+
with kerneltuner_cachefile.open(mode="r", encoding="utf-8") as fp:
9999
lines = fp.readlines()
100100
cache_start = False
101101
# write the new data to file

extra/bootstrap_hyperparams_visualizer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def reload_cache():
14-
with open("../cached_data_used/cache_files/bootstrap_hyperparamtuning.json", "r") as fh:
14+
with open("../cached_data_used/cache_files/bootstrap_hyperparamtuning.json", "r", encoding="utf-8") as fh:
1515
contents = fh.read()
1616
try:
1717
data = json.loads(contents)
@@ -329,8 +329,10 @@ def plot_parallel_coordinates(subfigure, hyperparams: dict, isnumeric: list, one
329329
scaled_cmap = cmap(y_valid)
330330
else:
331331
diff = y_valid_max - y_valid_min
332+
332333
def rescale(v):
333334
return (v - y_valid_min) / diff
335+
334336
scaled_cmap = cmap(rescale(y_valid))
335337

336338
# obtain the hyperparameters for a parallel coordinates plot

extra/max_draw_k_from_n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_indices(dist, draws):
118118
# path = '../../old_cached_data_used/cache_files/pnpoly_RTX_2070_SUPER.json'
119119
# path = '../../old_cached_data_used/cache_files/GEMM_RTX_2070_SUPER.json'
120120
path = "../../cached_data_used/cachefiles/GEMM/RTX_2080_Ti.json"
121-
with open(path, "r") as myfile:
121+
with open(path, "r", encoding="utf-8") as myfile:
122122
data = myfile.read()
123123
data = json.loads(data)
124124
times = []

src/autotuning_methodology/experiments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_experiment(filename: str) -> dict:
7777
schemafile = get_experiment_schema_filepath()
7878

7979
# open the experiment file and validate using the schema file
80-
with open(path) as file, open(schemafile) as schemafile:
80+
with open(path, "r", encoding="utf-8") as file, open(schemafile, "r", encoding="utf-8") as schemafile:
8181
schema = json.load(schemafile)
8282
experiment: dict = json.load(file)
8383
validate(instance=experiment, schema=schema)

src/autotuning_methodology/searchspace_statistics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def _to_valid_array(self, cache_values: list[dict], key: str, performance: bool)
283283
def _load(self) -> bool:
284284
"""Load the contents of the cache file."""
285285
filepath = self.get_valid_filepath()
286-
with open(filepath, "r") as fh:
286+
with open(filepath, "r", encoding="utf-8") as fh:
287287
print(f"Loading statistics for {filepath}...")
288288
# get the cache from the .json file
289289
orig_contents = fh.read()

tests/autotuning_methodology/integration/test_run_experiment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def validate_experiment_results(
204204

205205
# validate the contents
206206
schemafilepath = get_experiment_schema_filepath()
207-
with open(schemafilepath) as schemafile:
207+
with open(schemafilepath, "r", encoding="utf-8") as schemafile:
208208
schema = json.load(schemafile)
209209
validate(instance=experiment, schema=schema)
210210
kernel_name = experiment["kernels"][0]

tests/autotuning_methodology/integration/test_visualization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Integration test for visualization and quantification."""
1+
"""Integration test for visualization."""
22

33
from pathlib import Path
44

0 commit comments

Comments
 (0)