Skip to content

Expire deprecation of \mathcircled #16204

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

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions doc/api/next_api_changes/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,5 @@ mathtext
~~~~~~~~
- The ``\stackrel`` command (which behaved differently from its LaTeX version)
has been removed. Use ``\genfrac`` instead.
- The ``\mathcircled`` command has been removed. Directly use Unicode
characters, such as ``'\N{CIRCLED LATIN CAPITAL LETTER A}``, instead.
24 changes: 0 additions & 24 deletions lib/matplotlib/_mathtext_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2406,30 +2406,6 @@
[
(0x0041, 0x005a, 'it', 0xe22d), # A-Z
],
'circled':
{
'rm':
[
(0x0030, 0x0030, 'rm', 0x24ea), # 0
(0x0031, 0x0039, 'rm', 0x2460), # 1-9
(0x0041, 0x005a, 'rm', 0x24b6), # A-Z
(0x0061, 0x007a, 'rm', 0x24d0) # a-z
],
'it':
[
(0x0030, 0x0030, 'rm', 0x24ea), # 0
(0x0031, 0x0039, 'rm', 0x2460), # 1-9
(0x0041, 0x005a, 'it', 0x24b6), # A-Z
(0x0061, 0x007a, 'it', 0x24d0) # a-z
],
'bf':
[
(0x0030, 0x0030, 'bf', 0x24ea), # 0
(0x0031, 0x0039, 'bf', 0x2460), # 1-9
(0x0041, 0x005a, 'bf', 0x24b6), # A-Z
(0x0061, 0x007a, 'bf', 0x24d0) # a-z
],
},
'frak':
{
'rm':
Expand Down
8 changes: 1 addition & 7 deletions lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2299,8 +2299,7 @@ class Parser:

_dropsub_symbols = set(r'''\int \oint'''.split())

_fontnames = set(
"rm cal it tt sf bf default bb frak circled scr regular".split())
_fontnames = set("rm cal it tt sf bf default bb frak scr regular".split())

_function_names = set("""
arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim
Expand Down Expand Up @@ -2618,11 +2617,6 @@ def font(self):

@font.setter
def font(self, name):
if name == "circled":
cbook.warn_deprecated(
"3.1", name="\\mathcircled", obj_type="mathtext command",
alternative="unicode characters (e.g. '\\N{CIRCLED LATIN "
"CAPITAL LETTER A}' or '\\u24b6')")
if name in ('rm', 'it', 'bf'):
self.font_class = name
self._font = name
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
46 changes: 26 additions & 20 deletions lib/matplotlib/tests/test_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,19 @@
"\\phi \\chi \\psi")
all = [digits, uppercase, lowercase, uppergreek, lowergreek]

# Use stubs to reserve space if tests are removed
# stub should be of the form (None, N) where is the number of
# strings that used to be tested
# Add new tests at the end.
font_test_specs = [
([], all),
(['mathrm'], all),
(['mathbf'], all),
(['mathit'], all),
(['mathtt'], [digits, uppercase, lowercase]),
(['mathcircled'], [digits, uppercase, lowercase]),
(['mathrm', 'mathcircled'], [digits, uppercase, lowercase]),
(['mathbf', 'mathcircled'], [digits, uppercase, lowercase]),
(None, 3),
(None, 3),
(None, 3),
(['mathbb'], [digits, uppercase, lowercase,
r'\Gamma \Pi \Sigma \gamma \pi']),
(['mathrm', 'mathbb'], [digits, uppercase, lowercase,
Expand All @@ -146,27 +150,29 @@

font_tests = []
for fonts, chars in font_test_specs:
wrapper = ''.join([
' '.join(fonts),
' $',
*(r'\%s{' % font for font in fonts),
'%s',
*('}' for font in fonts),
'$',
])
for set in chars:
font_tests.append(wrapper % set)
if fonts is None:
font_tests.extend([None] * chars)
else:
wrapper = ''.join([
' '.join(fonts),
' $',
*(r'\%s{' % font for font in fonts),
'%s',
*('}' for font in fonts),
'$',
])
for set in chars:
font_tests.append(wrapper % set)

font_tests = list(filter(lambda x: x[1] is not None, enumerate(font_tests)))


@pytest.fixture
def baseline_images(request, fontset, index):
return ['%s_%s_%02d' % (request.param, fontset, index)]


# In the following two tests, use recwarn to suppress warnings regarding the
# deprecation of \stackrel and \mathcircled.


# recwarn suppresses warnings regarding the deprecation of \stackrel.
@pytest.mark.parametrize('index, test', enumerate(math_tests),
ids=[str(index) for index in range(len(math_tests))])
@pytest.mark.parametrize('fontset',
Expand All @@ -181,14 +187,14 @@ def test_mathtext_rendering(baseline_images, fontset, index, test, recwarn):
horizontalalignment='center', verticalalignment='center')


@pytest.mark.parametrize('index, test', enumerate(font_tests),
ids=[str(index) for index in range(len(font_tests))])
@pytest.mark.parametrize('index, test', font_tests,
ids=[str(index) for index, _ in font_tests])
@pytest.mark.parametrize('fontset',
['cm', 'stix', 'stixsans', 'dejavusans',
'dejavuserif'])
@pytest.mark.parametrize('baseline_images', ['mathfont'], indirect=True)
@image_comparison(baseline_images=None, extensions=['png'])
def test_mathfont_rendering(baseline_images, fontset, index, test, recwarn):
def test_mathfont_rendering(baseline_images, fontset, index, test):
matplotlib.rcParams['mathtext.fontset'] = fontset
fig = plt.figure(figsize=(5.25, 0.75))
fig.text(0.5, 0.5, test,
Expand Down