Skip to content

Avoid using np.r_, np.c_. #16142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/lines_bars_and_markers/filled_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def filled_hist(ax, edges, values, bottoms=None, orientation='v',
bottoms = 0
bottoms = np.broadcast_to(bottoms, values.shape)

values = np.r_[values, values[-1]]
bottoms = np.r_[bottoms, bottoms[-1]]
values = np.append(values, values[-1])
bottoms = np.append(bottoms, bottoms[-1])
if orientation == 'h':
return ax.fill_betweenx(edges, values, bottoms,
**kwargs)
Expand Down
10 changes: 4 additions & 6 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,9 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
# Check if closed and, if so, rotate contour so label is at edge
closed = _is_closed_polygon(slc)
if closed:
slc = np.r_[slc[ind:-1], slc[:ind + 1]]

slc = np.concatenate([slc[ind:-1], slc[:ind + 1]])
if len(lc): # Rotate lc also if not empty
lc = np.r_[lc[ind:-1], lc[:ind + 1]]

lc = np.concatenate([lc[ind:-1], lc[:ind + 1]])
ind = 0

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

Expand Down Expand Up @@ -568,7 +566,7 @@ def labels(self, inline, inline_spacing):
# functions, this is not necessary and should probably be
# eventually removed.
if _is_closed_polygon(lc):
slc = np.r_[slc0, slc0[1:2, :]]
slc = np.row_stack([slc0, slc0[1:2]])
else:
slc = slc0

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ def test_bar_pandas_indexed(pd):
@image_comparison(['hist_log'], remove_text=True)
def test_hist_log():
data0 = np.linspace(0, 1, 200)**3
data = np.r_[1-data0, 1+data0]
data = np.concatenate([1 - data0, 1 + data0])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.hist(data, fill=False, log=True)
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,8 @@ def transform_angles(self, angles, pts, radians=False, pushoff=1e-5):
if not radians:
angles = np.deg2rad(angles)
# Move a short distance away
pts2 = pts + pushoff * np.c_[np.cos(angles), np.sin(angles)]
pts2 = pts + pushoff * np.column_stack([np.cos(angles),
np.sin(angles)])
# Transform both sets of points
tpts = self.transform(pts)
tpts2 = self.transform(pts2)
Expand Down