Skip to content
Snippets Groups Projects
Commit e50d41ea authored by tomrink's avatar tomrink
Browse files

copy incoming array by default: normalize, scale

parent 0c0dbb8a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment