Skip to content

Commit 517b575

Browse files
committed
ENH: LogLocator: check for correct dimension of subs added
1 parent f8b425d commit 517b575

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/ticker.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,16 @@ def subs(self, subs):
21302130
"found '%s'." % subs)
21312131
self._subs = subs
21322132
else:
2133-
self._subs = np.asarray(subs, dtype=float)
2133+
try:
2134+
self._subs = np.asarray(subs, dtype=float)
2135+
except ValueError as e:
2136+
raise ValueError("If subs is not None and not a string, "
2137+
"it must be a sequence of float.") from e
2138+
if self._subs.ndim != 1:
2139+
raise ValueError("If subs is not None and not a string, it "
2140+
"must be a sequence of float. Hence subs "
2141+
"should have 1 dimension but it has {} "
2142+
"dimensions.".format(self._subs.ndim))
21342143

21352144
def __call__(self):
21362145
'Return the locations of the ticks'

0 commit comments

Comments
 (0)