diff --git a/modules/util/util.py b/modules/util/util.py index f82694540f0157dbe0c1bd45be82522c87b96e59..4aed787ef55c73fff3add136c180e164a3c204c9 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -435,7 +435,9 @@ def make_histogram(values, edges): return h -def normalize(data, param, mean_std_dict, add_noise=False, noise_scale=0.01, seed=None): +def normalize(data, param, mean_std_dict, add_noise=False, noise_scale=0.01, seed=None, copy=True): + if copy: + data = data.copy() if mean_std_dict.get(param) is None: return data @@ -462,7 +464,9 @@ def normalize(data, param, mean_std_dict, add_noise=False, noise_scale=0.01, see return data -def denormalize(data, param, mean_std_dict): +def denormalize(data, param, mean_std_dict, copy=True): + if copy: + data = data.copy() if mean_std_dict.get(param) is None: return data @@ -479,7 +483,9 @@ def denormalize(data, param, mean_std_dict): return data -def scale(data, param, mean_std_dict): +def scale(data, param, mean_std_dict, copy=True): + if copy: + data = data.copy() if mean_std_dict.get(param) is None: return data @@ -487,10 +493,6 @@ def scale(data, param, mean_std_dict): shape = data.shape data = data.flatten() - if mean_std_dict is None: - lo = np.nanmin(data) - hi = np.nanmax(data) - _, _, lo, hi = mean_std_dict.get(param) data -= lo