Skip to content

Commit 1842ff5

Browse files
oscargusmeeseeksmachine
authored andcommitted
Backport PR matplotlib#26566: MAINT: Numpy 2.0 deprecations for row_stack and in1d
1 parent c991a46 commit 1842ff5

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,7 +3674,7 @@ def apply_mask(arrays, mask):
36743674
# elow, ehigh = np.broadcast_to(...)
36753675
# return dep - elow * ~lolims, dep + ehigh * ~uplims
36763676
# except that broadcast_to would strip units.
3677-
low, high = dep + np.row_stack([-(1 - lolims), 1 - uplims]) * err
3677+
low, high = dep + np.vstack([-(1 - lolims), 1 - uplims]) * err
36783678
barcols.append(lines_func(
36793679
*apply_mask([indep, low, high], everymask), **eb_lines_style))
36803680
if self.name == "polar" and dep_axis == "x":
@@ -5482,8 +5482,8 @@ def get_interp_point(idx):
54825482
collection = mcoll.PolyCollection(polys, **kwargs)
54835483

54845484
# now update the datalim and autoscale
5485-
pts = np.row_stack([np.column_stack([ind[where], dep1[where]]),
5486-
np.column_stack([ind[where], dep2[where]])])
5485+
pts = np.vstack([np.hstack([ind[where, None], dep1[where, None]]),
5486+
np.hstack([ind[where, None], dep2[where, None]])])
54875487
if ind_dir == "y":
54885488
pts = pts[:, ::-1]
54895489

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,7 @@ def _update_patch_limits(self, patch):
24102410
vertices.append(curve([0, *dzeros, 1]))
24112411

24122412
if len(vertices):
2413-
vertices = np.row_stack(vertices)
2413+
vertices = np.vstack(vertices)
24142414

24152415
patch_trf = patch.get_transform()
24162416
updatex, updatey = patch_trf.contains_branch_seperately(self.transData)

lib/matplotlib/contour.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,13 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
511511
if closed:
512512
# This will remove contour if shorter than label
513513
if all(i != -1 for i in I):
514-
nlc.append(np.row_stack([xy2, lc[I[1]:I[0]+1], xy1]))
514+
nlc.append(np.vstack([xy2, lc[I[1]:I[0]+1], xy1]))
515515
else:
516516
# These will remove pieces of contour if they have length zero
517517
if I[0] != -1:
518-
nlc.append(np.row_stack([lc[:I[0]+1], xy1]))
518+
nlc.append(np.vstack([lc[:I[0]+1], xy1]))
519519
if I[1] != -1:
520-
nlc.append(np.row_stack([xy2, lc[I[1]:]]))
520+
nlc.append(np.vstack([xy2, lc[I[1]:]]))
521521

522522
# The current implementation removes contours completely
523523
# covered by labels. Uncomment line below to keep

lib/matplotlib/projections/polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def transform_path_non_affine(self, path):
121121
codes.extend(arc.codes[1:])
122122
else: # Interpolate.
123123
trs = cbook.simple_linear_interpolation(
124-
np.row_stack([(last_t, last_r), trs]),
124+
np.vstack([(last_t, last_r), trs]),
125125
path._interpolation_steps)[1:]
126126
xys.extend(self.transform_non_affine(trs))
127127
codes.extend([Path.LINETO] * len(trs))

lib/matplotlib/stackplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def stackplot(axes, x, *args,
6868
stacked area plot.
6969
"""
7070

71-
y = np.row_stack(args)
71+
y = np.vstack(args)
7272

7373
labels = iter(labels)
7474
if colors is not None:

lib/matplotlib/tests/test_triangulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ def test_trirefine():
10351035
x_verif, y_verif = np.meshgrid(x_verif, x_verif)
10361036
x_verif = x_verif.ravel()
10371037
y_verif = y_verif.ravel()
1038-
ind1d = np.in1d(np.around(x_verif*(2.5+y_verif), 8),
1038+
ind1d = np.isin(np.around(x_verif*(2.5+y_verif), 8),
10391039
np.around(x_refi*(2.5+y_refi), 8))
10401040
assert_array_equal(ind1d, True)
10411041

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ def set_zsort(self, zsort):
942942
def get_vector(self, segments3d):
943943
"""Optimize points for projection."""
944944
if len(segments3d):
945-
xs, ys, zs = np.row_stack(segments3d).T
946-
else: # row_stack can't stack zero arrays.
945+
xs, ys, zs = np.vstack(segments3d).T
946+
else: # vstack can't stack zero arrays.
947947
xs, ys, zs = [], [], []
948948
ones = np.ones(len(xs))
949949
self._vec = np.array([xs, ys, zs, ones])

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy