Skip to content

Commit dc864e2

Browse files
committed
Raise exception if there is no data to display.
1 parent b3c5bf0 commit dc864e2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spectral/algorithms/spymath.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ def get_histogram_cdf_points(data, cdf_vals, ignore=None, mask=None):
110110
data = data.ravel()
111111
if mask is not None:
112112
data = data[mask.ravel() != 0]
113+
if len(data) == 0:
114+
raise Exception('All pixels are masked.')
113115
if ignore is not None and ignore in data:
114116
data = data[np.where(data != ignore)]
117+
if len(data) == 0:
118+
raise Exception('No data to display after masking and ignoring.')
115119
isort = np.argsort(data)
116120
N = len(data)
117121
return [data[isort[int(x * (N - 1))]] for x in cdf_vals]

0 commit comments

Comments
 (0)