Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/deprecations/26444-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Passing non-int or sequence of non-int to ``Table.auto_set_column_width``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Column numbers are ints, and formerly passing any other type was effectively
ignored. This will become an error in the future.
8 changes: 0 additions & 8 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,6 @@ def get_underline_thickness(self, font, fontsize, dpi):
"""
raise NotImplementedError()

def get_used_characters(self):
"""
Get the set of characters that were used in the math
expression. Used by backends that need to subset fonts so
they know which glyphs to include.
"""
return self.used_characters

def get_sized_alternatives_for_symbol(self, fontname, sym):
"""
Override if your font provides multiple sizes of the same
Expand Down
19 changes: 11 additions & 8 deletions lib/matplotlib/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
Thanks to John Gill for providing the class and table.
"""

import numpy as np

from . import _api, _docstring
from .artist import Artist, allow_rasterization
from .patches import Rectangle
Expand Down Expand Up @@ -494,14 +496,15 @@ def auto_set_column_width(self, col):
col : int or sequence of ints
The indices of the columns to auto-scale.
"""
# check for col possibility on iteration
try:
iter(col)
except (TypeError, AttributeError):
self._autoColumns.append(col)
else:
for cell in col:
self._autoColumns.append(cell)
col1d = np.atleast_1d(col)
if not np.issubdtype(col1d.dtype, np.integer):
_api.warn_deprecated("3.8", name="col",
message="%(name)r must be an int or sequence of ints. "
"Passing other types is deprecated since %(since)s "
"and will be removed %(removal)s.")
return
for cell in col1d:
self._autoColumns.append(cell)

self.stale = True

Expand Down
16 changes: 8 additions & 8 deletions lib/matplotlib/tests/test_dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def test_PsfontsMap(monkeypatch):
monkeypatch.setattr(dr, 'find_tex_file', lambda x: x)
monkeypatch.setattr(dr, 'find_tex_file', lambda x: x.decode())

filename = str(Path(__file__).parent / 'baseline_images/dviread/test.map')
fontmap = dr.PsfontsMap(filename)
Expand All @@ -18,15 +18,15 @@ def test_PsfontsMap(monkeypatch):
assert entry.texname == key
assert entry.psname == b'PSfont%d' % n
if n not in [3, 5]:
assert entry.encoding == b'font%d.enc' % n
assert entry.encoding == 'font%d.enc' % n
elif n == 3:
assert entry.encoding == b'enc3.foo'
assert entry.encoding == 'enc3.foo'
# We don't care about the encoding of TeXfont5, which specifies
# multiple encodings.
if n not in [1, 5]:
assert entry.filename == b'font%d.pfa' % n
assert entry.filename == 'font%d.pfa' % n
else:
assert entry.filename == b'font%d.pfb' % n
assert entry.filename == 'font%d.pfb' % n
if n == 4:
assert entry.effects == {'slant': -0.1, 'extend': 1.2}
else:
Expand All @@ -37,13 +37,13 @@ def test_PsfontsMap(monkeypatch):
assert entry.encoding is None
entry = fontmap[b'TeXfont7']
assert entry.filename is None
assert entry.encoding == b'font7.enc'
assert entry.encoding == 'font7.enc'
entry = fontmap[b'TeXfont8']
assert entry.filename == b'font8.pfb'
assert entry.filename == 'font8.pfb'
assert entry.encoding is None
entry = fontmap[b'TeXfont9']
assert entry.psname == b'TeXfont9'
assert entry.filename == b'/absolute/font9.pfb'
assert entry.filename == '/absolute/font9.pfb'
# First of duplicates only.
entry = fontmap[b'TeXfontA']
assert entry.psname == b'PSfontA1'
Expand Down
15 changes: 11 additions & 4 deletions lib/matplotlib/tests/test_table.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.testing.decorators import image_comparison, check_figures_equal
import pytest

from matplotlib.table import CustomCell, Table
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.path import Path
from matplotlib.table import CustomCell, Table
from matplotlib.testing.decorators import image_comparison, check_figures_equal
from matplotlib.transforms import Bbox


Expand Down Expand Up @@ -176,7 +178,12 @@ def test_auto_column():
loc="center")
tb4.auto_set_font_size(False)
tb4.set_fontsize(12)
tb4.auto_set_column_width("-101")
with pytest.warns(mpl.MatplotlibDeprecationWarning,
match="'col' must be an int or sequence of ints"):
tb4.auto_set_column_width("-101") # type: ignore [arg-type]
with pytest.warns(mpl.MatplotlibDeprecationWarning,
match="'col' must be an int or sequence of ints"):
tb4.auto_set_column_width(["-101"]) # type: ignore [list-item]


def test_table_cells():
Expand Down