Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64fff76

Browse files
committed
API: add a check that we have at least one region
1 parent 20ef927 commit 64fff76

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

lib/matplotlib/colors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,9 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
14701470
self.vmax = boundaries[-1]
14711471
self.boundaries = np.asarray(boundaries)
14721472
self.N = len(self.boundaries)
1473+
if self.N < 2:
1474+
raise ValueError("You must provide at least 2 boundaries "
1475+
f"(1 region) but you passed in {boundaries!r}")
14731476
self.Ncmap = ncolors
14741477
self.extend = extend
14751478

0 commit comments

Comments
 (0)