8000 Minor cleanups. · matplotlib/matplotlib@9bf84be · GitHub
[go: up one dir, main page]

Skip to content

Commit 9bf84be

Browse files
committed
Minor cleanups.
1 parent 29f3a5c commit 9bf84be

File tree

5 files changed

+27
-38
lines changed

5 files changed

+27
-38
lines changed

lib/matplotlib/dviread.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,11 +893,10 @@ def __getitem__(self, texname):
893893
return self._parsed[texname]
894894
except KeyError:
895895
raise LookupError(
896-
f"An associated PostScript font (required by Matplotlib) "
897-
f"could not be found for TeX font {texname.decode('ascii')!r} "
898-
f"in {self._filename!r}; this problem can often be solved by "
899-
f"installing a suitable PostScript font package in your TeX "
900-
f"package manager") from None
896+
f"The font map {self._filename!r} is missing a PostScript font "
897+
f"associated to TeX font {texname.decode('ascii')!r}; this problem can "
898+
f"often be solved by installing a suitable PostScript font package in "
899+
f"your TeX package manager") from None
901900

902901
def _parse_and_cache_line(self, line):
903902
"""

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -251,28 +251,24 @@ def set_label_mode(self, mode):
251251
- "keep": Do not do anything.
252252
"""
253253
_api.check_in_list(["all", "L", "1", "keep"], mode=mode)
254-
is_last_row, is_first_col = (
255-
np.mgrid[:self._nrows, :self._ncols] == [[[self._nrows - 1]], [[0]]])
256-
if mode == "all":
257-
bottom = left = np.full((self._nrows, self._ncols), True)
258-
elif mode == "L":
259-
bottom = is_last_row
260-
left = is_first_col
261-
elif mode == "1":
262-
bottom = left = is_last_row & is_first_col
263-
else:
254+
if mode == "keep":
264255
return
265-
for i in range(self._nrows):
266-
for j in range(self._ncols):
267-
ax = self.axes_row[i][j]
268-
if isinstance(ax.axis, MethodType):
269-
bottom_axis = SimpleAxisArtist(ax.xaxis, 1, ax.spines["bottom"])
270-
left_axis = SimpleAxisArtist(ax.yaxis, 1, ax.spines["left"])
271-
else:
272-
bottom_axis = ax.axis["bottom"]
273-
left_axis = ax.axis["left"]
274-
bottom_axis.toggle(ticklabels=bottom[i, j], label=bottom[i, j])
275-
left_axis.toggle(ticklabels=left[i, j], label=left[i, j])
256+
for i, j in np.ndindex(self._nrows, self._ncols):
257+
ax = self.axes_row[i][j]
258+
if isinstance(ax.axis, MethodType):
259+
bottom_axis = SimpleAxisArtist(ax.xaxis, 1, ax.spines["bottom"])
260+
left_axis = SimpleAxisArtist(ax.yaxis, 1, ax.spines["left"])
261+
else:
262+
bottom_axis = ax.axis["bottom"]
263+
left_axis = ax.axis["left"]
264+
display_at_bottom = (i == self._nrows - 1 if mode == "L" else
265+
i == self._nrows - 1 and j == 0 if mode == "1" else
266+
True) # if mode == "all"
267+
display_at_left = (j == 0 if mode == "L" else
268+
i == self._nrows - 1 and j == 0 if mode == "1" else
269+
True) # if mode == "all"
270+
bottom_axis.toggle(ticklabels=display_at_bottom, label=display_at_bottom)
271+
left_axis.toggle(ticklabels=display_at_left, label=display_at_left)
276272

277273
def get_divider(self):
278274
return self._divider

lib/mpl_toolkits/axisartist/grid_finder.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@ def _find_line_box_crossings(xys, bbox):
3636
for u0, inside in [(umin, us > umin), (umax, us < umax)]:
3737
cross = []
3838
idxs, = (inside[:-1] ^ inside[1:]).nonzero()
39-
for idx in idxs:
40-
v = vs[idx] + (u0 - us[idx]) * dvs[idx] / dus[idx]
41-
if not vmin <= v <= vmax:
42-
continue
43-
crossing = (u0, v)[sl]
44-
theta = np.degrees(np.arctan2(*dxys[idx][::-1]))
45-
cross.append((crossing, theta))
46-
crossings.append(cross)
39+
vv = vs[idxs] + (u0 - us[idxs]) * dvs[idxs] / dus[idxs]
40+
crossings.append([
41+
((u0, v)[sl], np.degrees(np.arctan2(*dxy[::-1]))) # ((x, y), theta)
42+
for v, dxy in zip(vv, dxys[idxs]) if vmin <= v <= vmax])
4743
return crossings
4844

4945

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,9 +1100,7 @@ def _get_vector(self, segments3d):
11001100
be of shape (num_faces, num_vertices, 3).
11011101
"""
11021102
if isinstance(segments3d, np.ndarray):
1103-
if segments3d.ndim != 3 or segments3d.shape[-1] != 3:
1104-
raise ValueError("segments3d must be a MxNx3 array, but got "
1105-
f"shape {segments3d.shape}")
1103+
_api.check_shape((< 1E80 span class=pl-c1>None, None, 3), segments3d=segments3d)
11061104
if isinstance(segments3d, np.ma.MaskedArray):
11071105
self._faces = segments3d.data
11081106
self._invalid_vertices = segments3d.mask.any(axis=-1)

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ def test_poly3dcollection_verts_validation():
996996
art3d.Poly3DCollection(poly) # should be Poly3DCollection([poly])
997997

998998
poly = np.array(poly, dtype=float)
999-
with pytest.raises(ValueError, match=r'MxNx3 array'):
999+
with pytest.raises(ValueError, match=r'shape \(M, N, 3\)'):
10001000
art3d.Poly3DCollection(poly) # should be Poly3DCollection([poly])
10011001

10021002

0 commit comments

Comments
 (0)
0