Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa3e00d

Browse filesBrowse files
authored
Merge pull request #26444 from QuLogic/type-bugs
Fix some bugs found by typing
2 parents 83b3fef + 960efc3 commit aa3e00d
Copy full SHA for aa3e00d

File tree

Expand file treeCollapse file tree

6 files changed

+35
-29
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+35
-29
lines changed
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Passing non-int or sequence of non-int to ``Table.auto_set_column_width``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Column numbers are ints, and formerly passing any other type was effectively
5+
ignored. This will become an error in the future.

‎lib/matplotlib/_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext.py
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,6 @@ def get_underline_thickness(self, font, fontsize, dpi):
243243
"""
244244
raise NotImplementedError()
245245

246-
def get_used_characters(self):
247-
"""
248-
Get the set of characters that were used in the math
249-
expression. Used by backends that need to subset fonts so
250-
they know which glyphs to include.
251-
"""
252-
return self.used_characters
253-
254246
def get_sized_alternatives_for_symbol(self, fontname, sym):
255247
"""
256248
Override if your font provides multiple sizes of the same

‎lib/matplotlib/table.py

Copy file name to clipboardExpand all lines: lib/matplotlib/table.py
+11-8Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
Thanks to John Gill for providing the class and table.
2525
"""
2626

27+
import numpy as np
28+
2729
from . import _api, _docstring
2830
from .artist import Artist, allow_rasterization
2931
from .patches import Rectangle
@@ -494,14 +496,15 @@ def auto_set_column_width(self, col):
494496
col : int or sequence of ints
495497
The indices of the columns to auto-scale.
496498
"""
497-
# check for col possibility on iteration
498-
try:
499-
iter(col)
500-
except (TypeError, AttributeError):
501-
self._autoColumns.append(col)
502-
else:
503-
for cell in col:
504-
self._autoColumns.append(cell)
499+
col1d = np.atleast_1d(col)
500+
if not np.issubdtype(col1d.dtype, np.integer):
501+
_api.warn_deprecated("3.8", name="col",
502+
message="%(name)r must be an int or sequence of ints. "
503+
"Passing other types is deprecated since %(since)s "
504+
"and will be removed %(removal)s.")
505+
return
506+
for cell in col1d:
507+
self._autoColumns.append(cell)
505508

506509
self.stale = True
507510

‎lib/matplotlib/tests/test_dviread.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_dviread.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def test_PsfontsMap(monkeypatch):
10-
monkeypatch.setattr(dr, 'find_tex_file', lambda x: x)
10+
monkeypatch.setattr(dr, 'find_tex_file', lambda x: x.decode())
1111

1212
filename = str(Path(__file__).parent / 'baseline_images/dviread/test.map')
1313
fontmap = dr.PsfontsMap(filename)
@@ -18,15 +18,15 @@ def test_PsfontsMap(monkeypatch):
1818
assert entry.texname == key
1919
assert entry.psname == b'PSfont%d' % n
2020
if n not in [3, 5]:
21-
assert entry.encoding == b'font%d.enc' % n
21+
assert entry.encoding == 'font%d.enc' % n
2222
elif n == 3:
23-
assert entry.encoding == b'enc3.foo'
23+
assert entry.encoding == 'enc3.foo'
2424
# We don't care about the encoding of TeXfont5, which specifies
2525
# multiple encodings.
2626
if n not in [1, 5]:
27-
assert entry.filename == b'font%d.pfa' % n
27+
assert entry.filename == 'font%d.pfa' % n
2828
else:
29-
assert entry.filename == b'font%d.pfb' % n
29+
assert entry.filename == 'font%d.pfb' % n
3030
if n == 4:
3131
assert entry.effects == {'slant': -0.1, 'extend': 1.2}
3232
else:
@@ -37,13 +37,13 @@ def test_PsfontsMap(monkeypatch):
3737
assert entry.encoding is None
3838
entry = fontmap[b'TeXfont7']
3939
assert entry.filename is None
40-
assert entry.encoding == b'font7.enc'
40+
assert entry.encoding == 'font7.enc'
4141
entry = fontmap[b'TeXfont8']
42-
assert entry.filename == b'font8.pfb'
42+
assert entry.filename == 'font8.pfb'
4343
assert entry.encoding is None
4444
entry = fontmap[b'TeXfont9']
4545
assert entry.psname == b'TeXfont9'
46-
assert entry.filename == b'/absolute/font9.pfb'
46+
assert entry.filename == '/absolute/font9.pfb'
4747
# First of duplicates only.
4848
entry = fontmap[b'TeXfontA']
4949
assert entry.psname == b'PSfontA1'

‎lib/matplotlib/tests/test_table.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_table.py
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import matplotlib.pyplot as plt
21
import numpy as np
3-
from matplotlib.testing.decorators import image_comparison, check_figures_equal
2+
import pytest
43

5-
from matplotlib.table import CustomCell, Table
4+
import matplotlib.pyplot as plt
5+
import matplotlib as mpl
66
from matplotlib.path import Path
7+
from matplotlib.table import CustomCell, Table
8+
from matplotlib.testing.decorators import image_comparison, check_figures_equal
79
from matplotlib.transforms import Bbox
810

911

@@ -176,7 +178,12 @@ def test_auto_column():
176178
loc="center")
177179
tb4.auto_set_font_size(False)
178180
tb4.set_fontsize(12)
179-
tb4.auto_set_column_width("-101")
181+
with pytest.warns(mpl.MatplotlibDeprecationWarning,
182+
match="'col' must be an int or sequence of ints"):
183+
tb4.auto_set_column_width("-101") # type: ignore [arg-type]
184+
with pytest.warns(mpl.MatplotlibDeprecationWarning,
185+
match="'col' must be an int or sequence of ints"):
186+
tb4.auto_set_column_width(["-101"]) # type: ignore [list-item]
180187

181188

182189
def test_table_cells():

‎lib/matplotlib/tests/test_ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ class TestLogFormatterSciNotation:
971971
@pytest.mark.parametrize('base, value, expected', test_data)
972972
def test_basic(self, base, value, expected):
973973
formatter = mticker.LogFormatterSciNotation(base=base)
974-
formatter.sublabel = {1, 2, 5, 1.2}
975974
with mpl.rc_context({'text.usetex': False}):
976975
assert formatter(value) == expected
977976

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.