Skip to content

Commit 6ac4eff

Browse files
Copilotmmcky
andcommitted
Fix NumPy 2.0 compatibility: replace .ptp() method calls with np.ptp()
Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com>
1 parent aba2460 commit 6ac4eff

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lectures/match_transport.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,9 @@ def plot_H_z(self, figsize=(15, 8), range_x_axis=None, scatter=True):
575575
plt.axhline(0, color='black', linewidth=1)
576576
577577
# determine the step points for horizontal lines
578-
step = np.concatenate(([self.support_z.min() - .05 * self.support_z.ptp()],
578+
step = np.concatenate(([self.support_z.min() - .05 * np.ptp(self.support_z)],
579579
self.support_z,
580-
[self.support_z.max() + .05 * self.support_z.ptp()]))
580+
[self.support_z.max() + .05 * np.ptp(self.support_z)]))
581581
height = np.concatenate(([0], H_z, [0]))
582582
583583
# plot the horizontal lines of the step function
@@ -699,9 +699,9 @@ def plot_layers(self, figsize=(15, 8)):
699699
plt.figure(figsize=figsize)
700700
701701
# Plot H(z)
702-
step = np.concatenate(([self.support_z.min() - .05 * self.support_z.ptp()],
702+
step = np.concatenate(([self.support_z.min() - .05 * np.ptp(self.support_z)],
703703
self.support_z,
704-
[self.support_z.max() + .05 * self.support_z.ptp()]))
704+
[self.support_z.max() + .05 * np.ptp(self.support_z)]))
705705
height = np.concatenate((H_z, [0]))
706706
plt.step(step, height, where='post', color='black', label='CDF', zorder=1)
707707
@@ -984,7 +984,7 @@ def plot_layer_matching(self, layer, matching_layer):
984984
ax.spines['top'].set_color('none')
985985
ax.spines['right'].set_color('none')
986986
ax.yaxis.set_ticks([])
987-
ax.set_ylim(bottom= -self.support_z.ptp() / 100)
987+
ax.set_ylim(bottom= -np.ptp(self.support_z) / 100)
988988
989989
plt.show()
990990
@@ -1319,29 +1319,29 @@ def plot_matching(self, matching_off_diag, title, figsize=(15, 15),
13191319
ax.spines['top'].set_color('none')
13201320
ax.spines['right'].set_color('none')
13211321
ax.yaxis.set_ticks([])
1322-
ax.set_ylim(- self.X_types.ptp() / 10,
1323-
(max_height / 2) + self.X_types.ptp()*.01)
1322+
ax.set_ylim(- np.ptp(self.X_types) / 10,
1323+
(max_height / 2) + np.ptp(self.X_types)*.01)
13241324
13251325
# Plot H_z on the main axis if enabled
13261326
if plot_H_z:
13271327
H_z = np.cumsum(self.q_z)
13281328
13291329
step = np.concatenate(([self.support_z.min()
1330-
- .02 * self.support_z.ptp()],
1330+
- .02 * np.ptp(self.support_z)],
13311331
self.support_z,
13321332
[self.support_z.max()
1333-
+ .02 * self.support_z.ptp()]))
1333+
+ .02 * np.ptp(self.support_z)]))
13341334
1335-
H_z = H_z/H_z.ptp() * self.support_z.ptp() /2
1335+
H_z = H_z/np.ptp(H_z) * np.ptp(self.support_z) /2
13361336
height = np.concatenate(([0], H_z, [0]))
13371337
13381338
# Plot the compressed H_z on the same main x-axis
13391339
ax.step(step, height, color='green', lw=2,
13401340
label='$H_z$', where='post')
13411341
13421342
# Set the y-limit to keep H_z and maximum circle size in the plot
1343-
ax.set_ylim(np.min(H_z) - H_z.ptp() *.01,
1344-
np.maximum(np.max(H_z), max_height / 2) + H_z.ptp() *.01)
1343+
ax.set_ylim(np.min(H_z) - np.ptp(H_z) *.01,
1344+
np.maximum(np.max(H_z), max_height / 2) + np.ptp(H_z) *.01)
13451345
13461346
# Add label and legend for H_z
13471347
ax.legend(loc="upper right")
@@ -1907,7 +1907,7 @@ def plot_hierarchies(self, subpairs, scatter=True, range_x_axis=None):
19071907
19081908
if range_x_axis is not None:
19091909
ax.set_xlim(range_x_axis)
1910-
ax.set_ylim(- self.X_types.ptp() / 10,
1910+
ax.set_ylim(- np.ptp(self.X_types) / 10,
19111911
(range_x_axis[1] - range_x_axis[0]) / 2 )
19121912
19131913
# Title and layout settings for the main plot

0 commit comments

Comments
 (0)