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

Support for matplotlib-3.8.0 #36279

Merged
merged 1 commit into from
Sep 24, 2023
Merged

Conversation

tornaria
Copy link
Contributor

In matplotlib 3.8.0 there is a minor change that affects sagemath. The parameter to loc is supposed to be a string or an integer from 0 to 10 representing different positions. It used to work with sage integers, but now it doesn't.

This PR fixes it by coercing any numbers.Integral type into int before calling matplotlib.

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.

@@ -36,6 +36,8 @@
# ****************************************************************************

import os
import contextlib
import numbers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be moved local to the function to avoid the import until someone needs it. But only if matplotlib() is not called in a tight loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numbers is most probably already loaded, we just want to bring numbers.Integral in scope so I replaced it with from numbers import Integral. I don't see any difference between that and the next line from collections.abc import Iterable, etc.

As your other suggestion, I'm not importing contextlib anymore so it's only that one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks, it's not too important. I know that new top-level imports can sometimes slow down sage at startup but it's something that can easily be profiled and refactored later if it is really an issue.

@kiwifb
Copy link
Member

kiwifb commented Sep 17, 2023

I t appears CI is using cython-3 which of course lead to failures. But the PR makes the doctest failures in sage/plot/graphics.py go away when using matplotlib 3.8.0 so it looks good to me.

Copy link
Member

@kiwifb kiwifb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kiwifb approved this PR

@github-actions
Copy link

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

@vbraun vbraun merged commit 0fcf889 into sagemath:develop Sep 24, 2023
@mkoeppe mkoeppe added this to the sage-10.2 milestone Sep 24, 2023
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 19, 2023
sagemathgh-36320: Update `matplotlib` to 3.8.0, `pillow` to 10.0.1
    
<!-- ^^^^^
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 -->

<!-- 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". -->
<!-- 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.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#34816
- Depends on sagemath#36279
-
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36320
Reported by: Matthias Köppe
Reviewer(s): John H. Palmieri, Matthias Köppe
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.

5 participants