Skip to content

Commit a7f136e

Browse files
authored
Merge pull request #16142 from anntzer/nprc
Avoid using np.r_, np.c_.
2 parents 2fff6d7 + a3a0c67 commit a7f136e

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

examples/lines_bars_and_markers/filled_step.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def filled_hist(ax, edges, values, bottoms=None, orientation='v',
6464
bottoms = 0
6565
bottoms = np.broadcast_to(bottoms, values.shape)
6666

67-
values = np.r_[values, values[-1]]
68-
bottoms = np.r_[bottoms, bottoms[-1]]
67+
values = np.append(values, values[-1])
68+
bottoms = np.append(bottoms, bottoms[-1])
6969
if orientation == 'h':
7070
return ax.fill_betweenx(edges, values, bottoms,
7171
**kwargs)

lib/matplotlib/contour.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,9 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
331331
# Check if closed and, if so, rotate contour so label is at edge
332332
closed = _is_closed_polygon(slc)
333333
if closed:
334-
slc = np.r_[slc[ind:-1], slc[:ind + 1]]
335-
334+
slc = np.concatenate([slc[ind:-1], slc[:ind + 1]])
336335
if len(lc): # Rotate lc also if not empty
337-
lc = np.r_[lc[ind:-1], lc[:ind + 1]]
338-
336+
lc = np.concatenate([lc[ind:-1], lc[:ind + 1]])
339337
ind = 0
340338

341339
# Calculate path lengths
@@ -494,7 +492,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
494492
# if there isn't a vertex close enough
495493
if not np.allclose(xcmin, lc[imin]):
496494
# insert new data into the vertex list
497-
lc = np.r_[lc[:imin], np.array(xcmin)[None, :], lc[imin:]]
495+
lc = np.row_stack([lc[:imin], xcmin, lc[imin:]])
498496
# replace the path with the new one
499497
paths[segmin] = mpath.Path(lc)
500498

@@ -568,7 +566,7 @@ def labels(self, inline, inline_spacing):
568566
# functions, this is not necessary and should probably be
569567
# eventually removed.
570568
if _is_closed_polygon(lc):
571-
slc = np.r_[slc0, slc0[1:2, :]]
569+
slc = np.row_stack([slc0, slc0[1:2]])
572570
else:
573571
slc = slc0
574572

lib/matplotlib/tests/test_axes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ def test_bar_pandas_indexed(pd):
16811681
@image_comparison(['hist_log'], remove_text=True)
16821682
def test_hist_log():
16831683
data0 = np.linspace(0, 1, 200)**3
1684-
data = np.r_[1-data0, 1+data0]
1684+
data = np.concatenate([1 - data0, 1 + data0])
16851685
fig = plt.figure()
16861686
ax = fig.add_subplot(111)
16871687
ax.hist(data, fill=False, log=True)

lib/matplotlib/transforms.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,8 @@ def transform_angles(self, angles, pts, radians=False, pushoff=1e-5):
15761576
if not radians:
15771577
angles = np.deg2rad(angles)
15781578
# Move a short distance away
1579-
pts2 = pts + pushoff * np.c_[np.cos(angles), np.sin(angles)]
1579+
pts2 = pts + pushoff * np.column_stack([np.cos(angles),
1580+
np.sin(angles)])
15801581
# Transform both sets of points
15811582
tpts = self.transform(pts)
15821583
tpts2 = self.transform(pts2)

0 commit comments

Comments
 (0)