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

Skip to content

Commit 5ac46db

Browse files
committed
ENH: LogLocator: check for correct dimension of subs added
1 parent 6a61f93 commit 5ac46db

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
@@ -2127,7 +2127,16 @@ def subs(self, subs):
21272127
"found '%s'." % subs)
21282128
self._subs = subs
21292129
else:
2130-
self._subs = np.asarray(subs, dtype=float)
2130+
try:
2131+
self._subs = np.asarray(subs, dtype=float)
2132+
except ValueError as e:
2133+
raise ValueError("If subs is not None and not a string, "
2134+
"it must be a sequence of float.") from e
2135+
if subs.ndim != 1:
2136+
raise ValueError("If subs is not None and not a string, it "
2137+
"must be a sequence of float. Hence subs "
2138+
"should have 1 dimension but it has {} "
2139+
"dimensions.".format(subs.ndim))
21312140

21322141
def __call__(self):
21332142
'Return the locations of the ticks'

0 commit comments

Comments
 (0)