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

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 6, 2025

The match_transport.md lecture was failing with NumPy 2.0 due to the removal of the .ptp() method from ndarray objects. The error occurred when calling example_off_diag.plot_H_z():

AttributeError: `ptp` was removed from the ndarray class in NumPy 2.0. Use np.ptp(arr, ...) instead.

This PR replaces all instances of the deprecated .ptp() method with the NumPy 2.0 compatible np.ptp() function calls in the match_transport lecture:

  • self.support_z.ptp()np.ptp(self.support_z) (6 instances)
  • self.X_types.ptp()np.ptp(self.X_types) (4 instances)
  • H_z.ptp()np.ptp(H_z) (2 instances)

The changes are minimal and surgical - only method calls are replaced with function calls, preserving all existing functionality while ensuring compatibility with NumPy ≥ 2.0.

Testing: Verified with NumPy 2.3.2 that the previously failing example_off_diag.plot_H_z() call now executes successfully without errors.

Fixes #225.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

netlify bot commented Aug 6, 2025

Deploy Preview for lustrous-melomakarona-3ee73e ready!

Name Link
🔨 Latest commit 6ac4eff
🔍 Latest deploy log https://app.netlify.com/projects/lustrous-melomakarona-3ee73e/deploys/6892b715cd8b8300089be8f0
😎 Deploy Preview https://deploy-preview-229--lustrous-melomakarona-3ee73e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mmcky mmcky added the testing label Aug 6, 2025
Copy link

github-actions bot commented Aug 6, 2025

@Copilot Copilot AI changed the title [WIP] [match_transport] upgrades required for compatibility with numpy>=2 Fix NumPy 2.0 compatibility: replace deprecated .ptp() method calls with np.ptp() Aug 6, 2025
@Copilot Copilot AI requested a review from mmcky August 6, 2025 02:02
Copilot finished work on behalf of mmcky August 6, 2025 02:02
@mmcky
Copy link
Contributor

mmcky commented Aug 6, 2025

@copilot did a great job here. Thanks.

This has already been manual fixed in #215 but will use this as a good example of how to use copilot

Copilot finished work on behalf of mmcky August 6, 2025 02:06
@github-actions github-actions bot temporarily deployed to pull request August 6, 2025 02:16 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 6, 2025 02:17 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[match_transport] upgrades required for compatibility with numpy>=2
2 participants