Skip to content

Commit 0fcf889

Browse files
author
Release Manager
committed
gh-36279: Support for matplotlib-3.8.0 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. - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #36279 Reported by: Gonzalo Tornaría Reviewer(s): François Bissey, github-actions[bot], Gonzalo Tornaría, Michael Orlitzky
2 parents 991a463 + 92a8a96 commit 0fcf889

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sage/plot/graphics.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
# ****************************************************************************
3737

3838
import os
39+
from numbers import Integral
3940
from collections.abc import Iterable
4041
from math import isnan
4142
import sage.misc.verbose
@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
28742875
weight=lopts.pop('font_weight', 'medium'),
28752876
variant=lopts.pop('font_variant', 'normal'))
28762877
color = lopts.pop('back_color', 'white')
2878+
if 'loc' in lopts:
2879+
loc = lopts['loc']
2880+
if isinstance(loc, Integral):
2881+
# matplotlib 3.8 doesn't support sage integers
2882+
lopts['loc'] = int(loc)
28772883
leg = subplot.legend(prop=prop, **lopts)
28782884
if leg is None:
28792885
from warnings import warn

0 commit comments

Comments
 (0)