allow vmin/vmax = None as "no limit"
This commit is contained in:
@@ -6,17 +6,16 @@ def calc_apply_threshold(results, data, value=None, copy=False):
|
|||||||
if not apply_threshold:
|
if not apply_threshold:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
for k in ("threshold_min", "threshold_max"):
|
threshold_min = results.get("threshold_min")
|
||||||
if k not in results:
|
threshold_max = results.get("threshold_max")
|
||||||
return data
|
|
||||||
|
if threshold_min is None and threshold_max is None:
|
||||||
|
return data
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
threshold_value = results.get("threshold_value", "NaN")
|
threshold_value = results.get("threshold_value", "NaN")
|
||||||
value = 0 if threshold_value == "0" else np.nan #TODO
|
value = 0 if threshold_value == "0" else np.nan #TODO
|
||||||
|
|
||||||
threshold_min = float(results["threshold_min"])
|
|
||||||
threshold_max = float(results["threshold_max"])
|
|
||||||
|
|
||||||
if copy:
|
if copy:
|
||||||
data = data.copy() # do the following in-place changes on a copy
|
data = data.copy() # do the following in-place changes on a copy
|
||||||
|
|
||||||
@@ -30,10 +29,13 @@ def threshold(data, vmin, vmax, replacement):
|
|||||||
"""
|
"""
|
||||||
threshold data in place by replacing values < vmin and values > vmax with replacement
|
threshold data in place by replacing values < vmin and values > vmax with replacement
|
||||||
"""
|
"""
|
||||||
# if vmin > vmax, data will be overwritten entirely -- better to ensure vmin < vmax by switching them if needed
|
if vmin is not None and vmax is not None:
|
||||||
vmin, vmax = sorted((vmin, vmax))
|
# if vmin > vmax, data will be overwritten entirely -- better to ensure vmin < vmax by switching them if needed
|
||||||
data[data < vmin] = replacement
|
vmin, vmax = sorted((vmin, vmax))
|
||||||
data[data > vmax] = replacement
|
if vmin is not None:
|
||||||
|
data[data < vmin] = replacement
|
||||||
|
if vmax is not None:
|
||||||
|
data[data > vmax] = replacement
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user