Skip to content

Commit

Permalink
Made file read mode have explicit encodings to have consistent behavi…
Browse files Browse the repository at this point in the history
…our across operating systems
  • Loading branch information
fjwillemsen committed Jul 29, 2024
1 parent 2eb4e5f commit 630ecb0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cached_data_used/cachefiles/ktt_values_to_kerneltuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion extra/bootstrap_hyperparams_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion extra/max_draw_k_from_n.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion src/autotuning_methodology/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/autotuning_methodology/searchspace_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Integration test for visualization and quantification."""
"""Integration test for visualization."""

from pathlib import Path

Expand Down

0 comments on commit 630ecb0

Please sign in to comment.