diff --git a/cached_data_used/cachefiles/ktt_values_to_kerneltuner.py b/cached_data_used/cachefiles/ktt_values_to_kerneltuner.py index 79ca3d8..5b3d27f 100644 --- a/cached_data_used/cachefiles/ktt_values_to_kerneltuner.py +++ b/cached_data_used/cachefiles/ktt_values_to_kerneltuner.py @@ -95,7 +95,7 @@ # print(f"Replacing {kt_old_objective_value} with {kt_new_objective_value}") # load the individual lines of the file - with kerneltuner_cachefile.open(mode="r") as fp: + with kerneltuner_cachefile.open(mode="r", encoding="utf-8") as fp: lines = fp.readlines() cache_start = False # write the new data to file diff --git a/extra/bootstrap_hyperparams_visualizer.py b/extra/bootstrap_hyperparams_visualizer.py index e873a8c..90101d4 100755 --- a/extra/bootstrap_hyperparams_visualizer.py +++ b/extra/bootstrap_hyperparams_visualizer.py @@ -11,7 +11,7 @@ def reload_cache(): - with open("../cached_data_used/cache_files/bootstrap_hyperparamtuning.json", "r") as fh: + with open("../cached_data_used/cache_files/bootstrap_hyperparamtuning.json", "r", encoding="utf-8") as fh: contents = fh.read() try: data = json.loads(contents) @@ -329,8 +329,10 @@ def plot_parallel_coordinates(subfigure, hyperparams: dict, isnumeric: list, one scaled_cmap = cmap(y_valid) else: diff = y_valid_max - y_valid_min + def rescale(v): return (v - y_valid_min) / diff + scaled_cmap = cmap(rescale(y_valid)) # obtain the hyperparameters for a parallel coordinates plot diff --git a/extra/max_draw_k_from_n.py b/extra/max_draw_k_from_n.py index e3d6093..40bcf8d 100644 --- a/extra/max_draw_k_from_n.py +++ b/extra/max_draw_k_from_n.py @@ -118,7 +118,7 @@ def get_indices(dist, draws): # path = '../../old_cached_data_used/cache_files/pnpoly_RTX_2070_SUPER.json' # path = '../../old_cached_data_used/cache_files/GEMM_RTX_2070_SUPER.json' path = "../../cached_data_used/cachefiles/GEMM/RTX_2080_Ti.json" - with open(path, "r") as myfile: + with open(path, "r", encoding="utf-8") as myfile: data = myfile.read() data = json.loads(data) times = [] diff --git a/src/autotuning_methodology/experiments.py b/src/autotuning_methodology/experiments.py index 187f359..382347b 100755 --- a/src/autotuning_methodology/experiments.py +++ b/src/autotuning_methodology/experiments.py @@ -77,7 +77,7 @@ def get_experiment(filename: str) -> dict: schemafile = get_experiment_schema_filepath() # open the experiment file and validate using the schema file - with open(path) as file, open(schemafile) as schemafile: + with open(path, "r", encoding="utf-8") as file, open(schemafile, "r", encoding="utf-8") as schemafile: schema = json.load(schemafile) experiment: dict = json.load(file) validate(instance=experiment, schema=schema) diff --git a/src/autotuning_methodology/searchspace_statistics.py b/src/autotuning_methodology/searchspace_statistics.py index d4276d3..9fe2c06 100644 --- a/src/autotuning_methodology/searchspace_statistics.py +++ b/src/autotuning_methodology/searchspace_statistics.py @@ -283,7 +283,7 @@ def _to_valid_array(self, cache_values: list[dict], key: str, performance: bool) def _load(self) -> bool: """Load the contents of the cache file.""" filepath = self.get_valid_filepath() - with open(filepath, "r") as fh: + with open(filepath, "r", encoding="utf-8") as fh: print(f"Loading statistics for {filepath}...") # get the cache from the .json file orig_contents = fh.read() diff --git a/tests/autotuning_methodology/integration/test_run_experiment.py b/tests/autotuning_methodology/integration/test_run_experiment.py index 3fabb63..35b7220 100644 --- a/tests/autotuning_methodology/integration/test_run_experiment.py +++ b/tests/autotuning_methodology/integration/test_run_experiment.py @@ -204,7 +204,7 @@ def validate_experiment_results( # validate the contents schemafilepath = get_experiment_schema_filepath() - with open(schemafilepath) as schemafile: + with open(schemafilepath, "r", encoding="utf-8") as schemafile: schema = json.load(schemafile) validate(instance=experiment, schema=schema) kernel_name = experiment["kernels"][0] diff --git a/tests/autotuning_methodology/integration/test_visualization.py b/tests/autotuning_methodology/integration/test_visualization.py index 9247f78..97e34dc 100644 --- a/tests/autotuning_methodology/integration/test_visualization.py +++ b/tests/autotuning_methodology/integration/test_visualization.py @@ -1,4 +1,4 @@ -"""Integration test for visualization and quantification.""" +"""Integration test for visualization.""" from pathlib import Path