Skip to content

Commit 3a60c07

Browse files
matthewturkmeeseeksmachine
authored andcommitted
Backport PR yt-project#4725: BUG: handle deprecation warnings from numpy 2.0.0dev0 (np.row_stack -> np.vstack and np.in1d -> np.isin)
1 parent a6c36e1 commit 3a60c07

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

yt/data_objects/particle_trajectories.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ def __init__(
9999
):
100100
dd = ds.all_data()
101101
newtags = dd[fds["particle_index"]].d.astype("int64")
102-
mask = np.in1d(newtags, indices, assume_unique=True)
102+
mask = np.isin(newtags, indices, assume_unique=True)
103103
sort = np.argsort(newtags[mask])
104-
array_indices = np.where(np.in1d(indices, newtags, assume_unique=True))[0]
104+
array_indices = np.where(np.isin(indices, newtags, assume_unique=True))[0]
105105
self.array_indices.append(array_indices)
106106
self.masks.append(mask)
107107
self.sorts.append(sort)
@@ -333,7 +333,7 @@ def trajectory_from_index(self, index):
333333
... )
334334
>>> plt.savefig("orbit")
335335
"""
336-
mask = np.in1d(self.indices, (index,), assume_unique=True)
336+
mask = np.isin(self.indices, (index,), assume_unique=True)
337337
if not np.any(mask):
338338
print("The particle index %d is not in the list!" % (index))
339339
raise IndexError

yt/frontends/adaptahop/data_structures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _set_halo_member_data(self):
348348

349349
# Build subregion that only contains halo particles
350350
reg = sph.cut_region(
351-
['np.in1d(obj[("io", "particle_identity")].astype("int64"), members)'],
351+
['np.isin(obj[("io", "particle_identity")].astype("int64"), members)'],
352352
locals={"members": members, "np": np},
353353
)
354354

yt/visualization/plot_modifications.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2480,8 +2480,8 @@ def __call__(self, plot):
24802480
# more convenient to swap the x, y values here before final roll
24812481
x0, y0 = l_cy[0] # x, y values of start points
24822482
x1, y1 = l_cy[1] # x, y values of end points
2483-
l_cy[0] = np.row_stack([y0, x0]) # swap x, y for start points
2484-
l_cy[1] = np.row_stack([y1, x1]) # swap x, y for end points
2483+
l_cy[0] = np.vstack([y0, x0]) # swap x, y for start points
2484+
l_cy[1] = np.vstack([y1, x1]) # swap x, y for end points
24852485
# convert back to shape (nlines, 2, 2)
24862486
l_cy = np.rollaxis(l_cy, 2, 0)
24872487
# create line collection and add it to the plot

0 commit comments

Comments
 (0)