Skip to content
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

Fix incompatibilities with NumPy 2.0 #1107

Merged
merged 2 commits into from
Jun 29, 2024
Merged

Conversation

bcoconni
Copy link
Member

Following the release of Numpy 2.0, the function numpy.mat has been deprecated. It is recommended by the Numpy 2.0 migration guide to replace numpy.mat by numpy.asmatrix. However:

  • We want to support Numpy 1.xx and it is unclear in the documentation when the function np.asmatrix has been introduced. In particular, it might not be supported for older versions of Numpy.
  • We have been using np.matrix for the last 6 years (see below) and NumPy 1.xx never complained.

Tb2l = np.matrix([[ math.cos(theta), 0.0, math.sin(theta)],
[ 0.0, 1.0, 0.0],
[-math.sin(theta), 0.0, math.cos(theta)]])
Ts2b = np.matrix([[-1.0, 0.0, 0.0],
[ 0.0, 1.0, 0.0],
[ 0.0, 0.0, -1.0]])

Ma = np.matrix([[ math.cos(a), 0.0, math.sin(a)],
[ 0.0, 1.0, 0.0],
[ -math.sin(a), 0.0, math.cos(a)]])
Mb = np.matrix([[ math.cos(b), math.sin(b), 0.0],
[ -math.sin(b), math.cos(b), 0.0],
[ 0.0, 0.0, 1.0]])
Mc = np.matrix([[ 1.0, 0.0, 0.0],
[ 0.0, math.cos(c), -math.sin(c)],
[ 0.0, math.sin(c), math.cos(c)]])

As our CI workflow installs NumPy 2.0 by default on the MacOSX ARM64 platform, the current PR replaces all occurrences of numpy.mat by numpy.matrix to support Numpy 1.xx and 2.0.

Copy link

codecov bot commented Jun 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 24.94%. Comparing base (e33e184) to head (d00a703).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1107   +/-   ##
=======================================
  Coverage   24.94%   24.94%           
=======================================
  Files         170      170           
  Lines       18235    18235           
=======================================
  Hits         4548     4548           
  Misses      13687    13687           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bcoconni bcoconni merged commit c867cc7 into JSBSim-Team:master Jun 29, 2024
30 checks passed
@bcoconni bcoconni deleted the NumPy2 branch June 29, 2024 18:10
bcoconni added a commit to bcoconni/jsbsim that referenced this pull request Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant