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

numpy-1.25 compatibility #36255

Merged
merged 2 commits into from
Sep 16, 2023
Merged

Conversation

orlitzky
Copy link
Contributor

Fixes two doctest failures with numpy-1.25.x. One is a warning from pythran that needs to be hidden (to avoid requiring a bleeding-edge version of pythran), and the other is a buggy doctest that now triggers a numpy warning.

Some numpy.random signatures changed in numpy-1.25.x, and pythran
normally wants to warn about those. It's not clear, however, whether
or not the numpy changes will be reverted. Until we know,
pythran-0.14.0 has a special case to ignore the warnings for
numpy.random. Here we ignore those warnings in the doctest parser as
well, allowing older versions of pythran to be used with numpy-1.25.x.
One of the tests for the "Computational Math..." book is plotting
lines on a vector field by calling scipy.integrate.odeint repeatedly.
This test runs,

  y = integrate.odeint(f, k, t)
  p += line(zip(t, flatten(y)))

in an attempt to flatten y, which is returned as a numpy array of
1-dimensional numpy arrays. However, flatten() isn't smart enough to
handle that: it returns a list of 1-dimensional numpy arrays rather
than a list of floating point numbers. And numpy-1.25.x now warns
about casting 1-dimensional arrays to float deep in our plotting
infrastructure.

Instead, we now call y.tolist() before passing it to flatten(), and
this does the right thing.
@github-actions
Copy link

Documentation preview for this PR (built with commit 63edc00; changes) is ready! 🎉

@vbraun vbraun merged commit 238b1dc into sagemath:develop Sep 16, 2023
19 of 25 checks passed
@mkoeppe mkoeppe added this to the sage-10.2 milestone Sep 16, 2023
@orlitzky orlitzky deleted the numpy-1.25-warnings branch September 22, 2023 00:22
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 1, 2023
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

NumPy 1.26 provides Python 3.12 support and Cython 3 compatibility.

1.26.0 was released 2023-09-16.

As NumPy has changed its build system from setuptools-pinned-to-an-
ancient-version to meson_python, we get rid of our ancient version of
`setuptools`. The SPKGs `setuptools` and `setuptools_wheel` now ship the
same (current) version.

- [x] Check portability run:
https://github.com/mkoeppe/sage/actions/runs/5959239800
- [ ] Check SAGE_FAT_BINARY

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
Resolves sagemath#34816
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies
- Depends on sagemath#36112 (for the `meson_python` upgrades, merged here)
- Depends on sagemath#35404 (merged here as
part of above)
- Depends on sagemath#35810 (merged here as part of above)
- Depends on sagemath#36110 (merged here)
- Depends on sagemath#36263 (merged here)
- Depends on sagemath#36238 (merged here)
- Depends on sagemath#36255 (merged here)
<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36123
Reported by: Matthias Köppe
Reviewer(s):
vbraun pushed a commit that referenced this pull request Oct 8, 2023
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

NumPy 1.26 provides Python 3.12 support and Cython 3 compatibility.

1.26.0 was released 2023-09-16.

As NumPy has changed its build system from setuptools-pinned-to-an-
ancient-version to meson_python, we get rid of our ancient version of
`setuptools`. The SPKGs `setuptools` and `setuptools_wheel` now ship the
same (current) version.

- [x] Check portability run:
https://github.com/mkoeppe/sage/actions/runs/5959239800
- [ ] Check SAGE_FAT_BINARY

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
Resolves #34816
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies
- Depends on #36112 (for the `meson_python` upgrades, merged here)
- Depends on #35404 (merged here as
part of above)
- Depends on #35810 (merged here as part of above)
- Depends on #36110 (merged here)
- Depends on #36263 (merged here)
- Depends on #36238 (merged here)
- Depends on #36255 (merged here)
<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #36123
Reported by: Matthias Köppe
Reviewer(s):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants