| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1260,3 +1260,12 @@ def test_remove_overlap(remove_overlapping_locs, expected_num): | |||
| 1260 | 1260 | assert len(ax.xaxis.get_minor_ticks()) == expected_num | |
| 1261 | 1261 | assert len(ax.xaxis.get_minorticklabels()) == expected_num | |
| 1262 | 1262 | assert len(ax.xaxis.get_minorticklines()) == expected_num*2 | |
| 1263 | + | ||
| 1264 | + | ||
| 1265 | + @pytest.mark.parametrize('sub', [ | ||
| 1266 | + ['hi', 'aardvark'], | ||
| 1267 | + np.zeros((2, 2))]) | ||
| 1268 | + def test_bad_locator_subs(sub): | ||
| 1269 | + ll = mticker.LogLocator() | ||
| 1270 | + with pytest.raises(ValueError): | ||
| 1271 | + ll.subs(sub) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2382,7 +2382,16 @@ def subs(self, subs): | |||
| 2382 | 2382 | cbook._check_in_list(('all', 'auto'), subs=subs) | |
| 2383 | 2383 | self._subs = subs | |
| 2384 | 2384 | else: | |
| 2385 | - self._subs = np.asarray(subs, dtype=float) | ||
| 2385 | + try: | ||
| 2386 | + self._subs = np.asarray(subs, dtype=float) | ||
| 2387 | + except ValueError as e: | ||
| 2388 | + raise ValueError("subs must be None, 'all', 'auto' or " | ||
| 2389 | + "a sequence of floats, not " | ||
| 2390 | + "{}.".format(subs)) from e | ||
| 2391 | + if self._subs.ndim != 1: | ||
| 2392 | + raise ValueError("A sequence passed to subs must be " | ||
| 2393 | + "1-dimensional, not " | ||
| 2394 | + "{}-dimensional.".format(self._subs.ndim)) | ||
| 2386 | 2395 | ||
| 2387 | 2396 | def __call__(self): | |
| 2388 | 2397 | 'Return the locations of the ticks' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments