Skip to content

Fix NumPy 2.0 compatibility: replace deprecated .ptp() method calls with np.ptp() #229

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
26 changes: 13 additions & 13 deletions lectures/match_transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ def plot_H_z(self, figsize=(15, 8), range_x_axis=None, scatter=True):
plt.axhline(0, color='black', linewidth=1)

# determine the step points for horizontal lines
step = np.concatenate(([self.support_z.min() - .05 * self.support_z.ptp()],
step = np.concatenate(([self.support_z.min() - .05 * np.ptp(self.support_z)],
self.support_z,
[self.support_z.max() + .05 * self.support_z.ptp()]))
[self.support_z.max() + .05 * np.ptp(self.support_z)]))
height = np.concatenate(([0], H_z, [0]))

# plot the horizontal lines of the step function
Expand Down Expand Up @@ -699,9 +699,9 @@ def plot_layers(self, figsize=(15, 8)):
plt.figure(figsize=figsize)

# Plot H(z)
step = np.concatenate(([self.support_z.min() - .05 * self.support_z.ptp()],
step = np.concatenate(([self.support_z.min() - .05 * np.ptp(self.support_z)],
self.support_z,
[self.support_z.max() + .05 * self.support_z.ptp()]))
[self.support_z.max() + .05 * np.ptp(self.support_z)]))
height = np.concatenate((H_z, [0]))
plt.step(step, height, where='post', color='black', label='CDF', zorder=1)

Expand Down Expand Up @@ -984,7 +984,7 @@ def plot_layer_matching(self, layer, matching_layer):
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
ax.yaxis.set_ticks([])
ax.set_ylim(bottom= -self.support_z.ptp() / 100)
ax.set_ylim(bottom= -np.ptp(self.support_z) / 100)

plt.show()

Expand Down Expand Up @@ -1319,29 +1319,29 @@ def plot_matching(self, matching_off_diag, title, figsize=(15, 15),
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
ax.yaxis.set_ticks([])
ax.set_ylim(- self.X_types.ptp() / 10,
(max_height / 2) + self.X_types.ptp()*.01)
ax.set_ylim(- np.ptp(self.X_types) / 10,
(max_height / 2) + np.ptp(self.X_types)*.01)

# Plot H_z on the main axis if enabled
if plot_H_z:
H_z = np.cumsum(self.q_z)

step = np.concatenate(([self.support_z.min()
- .02 * self.support_z.ptp()],
- .02 * np.ptp(self.support_z)],
self.support_z,
[self.support_z.max()
+ .02 * self.support_z.ptp()]))
+ .02 * np.ptp(self.support_z)]))

H_z = H_z/H_z.ptp() * self.support_z.ptp() /2
H_z = H_z/np.ptp(H_z) * np.ptp(self.support_z) /2
height = np.concatenate(([0], H_z, [0]))

# Plot the compressed H_z on the same main x-axis
ax.step(step, height, color='green', lw=2,
label='$H_z$', where='post')

# Set the y-limit to keep H_z and maximum circle size in the plot
ax.set_ylim(np.min(H_z) - H_z.ptp() *.01,
np.maximum(np.max(H_z), max_height / 2) + H_z.ptp() *.01)
ax.set_ylim(np.min(H_z) - np.ptp(H_z) *.01,
np.maximum(np.max(H_z), max_height / 2) + np.ptp(H_z) *.01)

# Add label and legend for H_z
ax.legend(loc="upper right")
Expand Down Expand Up @@ -1907,7 +1907,7 @@ def plot_hierarchies(self, subpairs, scatter=True, range_x_axis=None):

if range_x_axis is not None:
ax.set_xlim(range_x_axis)
ax.set_ylim(- self.X_types.ptp() / 10,
ax.set_ylim(- np.ptp(self.X_types) / 10,
(range_x_axis[1] - range_x_axis[0]) / 2 )

# Title and layout settings for the main plot
Expand Down
Loading