Skip to content

Commit 487fc05

Browse files
authored
Merge pull request #16514 from QuLogic/reviews
Various delayed PR reviews
2 parents 8990a43 + d194bc8 commit 487fc05

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

examples/animation/bayes_update.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def __init__(self, ax, prob=0.5):
4141
def __call__(self, i):
4242
# This way the plot can continuously run and we just keep
4343
# watching new realizations of the process
44+
if i == 0:
45+
self.success = 0
46+
self.line.set_data([], [])
47+
return self.line,
4448

4549
# Choose success based on exceed a threshold with a uniform pick
4650
if np.random.rand(1,) < self.prob:

examples/scales/logit_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
xmax = 10
1515
x = np.linspace(-xmax, xmax, 10000)
1616
cdf_norm = [math.erf(w / np.sqrt(2)) / 2 + 1 / 2 for w in x]
17-
cdf_laplacian = [1 / 2 * np.exp(w) if w < 0 else 1 - 1 / 2 * np.exp(-w)
18-
for w in x]
17+
cdf_laplacian = np.where(x < 0, 1 / 2 * np.exp(x), 1 - 1 / 2 * np.exp(-x))
1918
cdf_cauchy = np.arctan(x) / np.pi + 1 / 2
2019

2120
fig, axs = plt.subplots(nrows=3, ncols=2, figsize=(6.4, 8.5))

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,14 @@ def baseline_images(request, fontset, index):
172172
return ['%s_%s_%02d' % (request.param, fontset, index)]
173173

174174

175-
# recwarn suppresses warnings regarding the deprecation of \stackrel.
176175
@pytest.mark.parametrize('index, test', enumerate(math_tests),
177176
ids=[str(index) for index in range(len(math_tests))])
178177
@pytest.mark.parametrize('fontset',
179178
['cm', 'stix', 'stixsans', 'dejavusans',
180179
'dejavuserif'])
181180
@pytest.mark.parametrize('baseline_images', ['mathtext'], indirect=True)
182181
@image_comparison(baseline_images=None)
183-
def test_mathtext_rendering(baseline_images, fontset, index, test, recwarn):
182+
def test_mathtext_rendering(baseline_images, fontset, index, test):
184183
matplotlib.rcParams['mathtext.fontset'] = fontset
185184
fig = plt.figure(figsize=(5.25, 0.75))
186185
fig.text(0.5, 0.5, test,

lib/matplotlib/tests/test_mlab.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,8 @@ def test_spectral_helper_raises(self):
11071107
{"y": self.y+1, "mode": "phase"},
11081108
{"mode": "spam"}, # Bad mode.
11091109
{"y": self.y, "sides": "eggs"}, # Bad sides.
1110-
{"NFFT": 10, "noverlap": 20}, # noverlap > NFFT.
1111-
{"y": self.y, "NFFT": 10, "noverlap": 20}, # noverlap == NFFT.
1110+
{"y": self.y, "NFFT": 10, "noverlap": 20}, # noverlap > NFFT.
1111+
{"NFFT": 10, "noverlap": 10}, # noverlap == NFFT.
11121112
{"y": self.y, "NFFT": 10,
11131113
"window": np.ones(9)}, # len(win) != NFFT.
11141114
]:
@@ -1361,6 +1361,7 @@ def test_spectrum(self, kind):
13611361
assert spec.shape == freqs.shape
13621362
if kind == "magnitude":
13631363
self.check_maxfreq(spec, fsp, self.fstims)
1364+
self.check_freqs(spec, freqs, fsp, self.fstims)
13641365

13651366
@pytest.mark.parametrize(
13661367
'kwargs',

lib/matplotlib/tests/test_ticker.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from numpy.testing import assert_almost_equal, assert_array_equal
1010
import pytest
1111

12-
import matplotlib
1312
import matplotlib as mpl
1413
from matplotlib import cbook
1514
import matplotlib.pyplot as plt
@@ -70,7 +69,7 @@ def test_view_limits(self):
7069
"""
7170
Test basic behavior of view limits.
7271
"""
73-
with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
72+
with mpl.rc_context({'axes.autolimit_mode': 'data'}):
7473
loc = mticker.MultipleLocator(base=3.147)
7574
assert_almost_equal(loc.view_limits(-5, 5), (-5, 5))
7675

@@ -79,7 +78,7 @@ def test_view_limits_round_numbers(self):
7978
Test that everything works properly with 'round_numbers' for auto
8079
limit.
8180
"""
82-
with matplotlib.rc_context({'axes.autolimit_mode': 'round_numbers'}):
81+
with mpl.rc_context({'axes.autolimit_mode': 'round_numbers'}):
8382
loc = mticker.MultipleLocator(base=3.147)
8483
assert_almost_equal(loc.view_limits(-4, 4), (-6.294, 6.294))
8584

@@ -130,7 +129,7 @@ def test_low_number_of_majorticks(
130129
# This test is meant to verify the parameterization for
131130
# test_number_of_minor_ticks
132131
def test_using_all_default_major_steps(self):
133-
with matplotlib.rc_context({'_internal.classic_mode': False}):
132+
with mpl.rc_context({'_internal.classic_mode': False}):
134133
majorsteps = [x[0] for x in self.majorstep_minordivisions]
135134
np.testing.assert_allclose(majorsteps,
136135
mticker.AutoLocator()._steps)
@@ -516,7 +515,7 @@ class TestScalarFormatter:
516515
@pytest.mark.parametrize('unicode_minus, result',
517516
[(True, "\N{MINUS SIGN}1"), (False, "-1")])
518517
def test_unicode_minus(self, unicode_minus, result):
519-
matplotlib.rcParams['axes.unicode_minus'] = unicode_minus
518+
mpl.rcParams['axes.unicode_minus'] = unicode_minus
520519
assert (
521520
plt.gca().xaxis.get_major_formatter().format_data_short(-1).strip()
522521
== result)
@@ -540,7 +539,7 @@ def test_offset_value(self, left, right, offset):
540539

541540
@pytest.mark.parametrize('use_offset', use_offset_data)
542541
def test_use_offset(self, use_offset):
543-
with matplotlib.rc_context({'axes.formatter.useoffset': use_offset}):
542+
with mpl.rc_context({'axes.formatter.useoffset': use_offset}):
544543
tmp_form = mticker.ScalarFormatter()
545544
assert use_offset == tmp_form.get_useOffset()
546545

@@ -618,8 +617,7 @@ class TestLogFormatterMathtext:
618617

619618
@pytest.mark.parametrize('min_exponent, value, expected', test_data)
620619
def test_min_exponent(self, min_exponent, value, expected):
621-
with matplotlib.rc_context({'axes.formatter.min_exponent':
622-
min_exponent}):
620+
with mpl.rc_context({'axes.formatter.min_exponent': min_exponent}):
623621
assert self.fmt(value) == expected
624622

625623

@@ -648,7 +646,7 @@ class TestLogFormatterSciNotation:
648646
def test_basic(self, base, value, expected):
649647
formatter = mticker.LogFormatterSciNotation(base=base)
650648
formatter.sublabel = {1, 2, 5, 1.2}
651-
with matplotlib.rc_context({'text.usetex': False}):
649+
with mpl.rc_context({'text.usetex': False}):
652650
assert formatter(value) == expected
653651

654652

@@ -1231,38 +1229,38 @@ class TestPercentFormatter:
12311229
def test_basic(self, xmax, decimals, symbol,
12321230
x, display_range, expected):
12331231
formatter = mticker.PercentFormatter(xmax, decimals, symbol)
1234-
with matplotlib.rc_context(rc={'text.usetex': False}):
1232+
with mpl.rc_context(rc={'text.usetex': False}):
12351233
assert formatter.format_pct(x, display_range) == expected
12361234

12371235
@pytest.mark.parametrize('is_latex, usetex, expected', latex_data)
12381236
def test_latex(self, is_latex, usetex, expected):
12391237
fmt = mticker.PercentFormatter(symbol='\\{t}%', is_latex=is_latex)
1240-
with matplotlib.rc_context(rc={'text.usetex': usetex}):
1238+
with mpl.rc_context(rc={'text.usetex': usetex}):
12411239
assert fmt.format_pct(50, 100) == expected
12421240

12431241

12441242
def test_majformatter_type():
12451243
fig, ax = plt.subplots()
12461244
with pytest.raises(TypeError):
1247-
ax.xaxis.set_major_formatter(matplotlib.ticker.LogLocator())
1245+
ax.xaxis.set_major_formatter(mticker.LogLocator())
12481246

12491247

12501248
def test_minformatter_type():
12511249
fig, ax = plt.subplots()
12521250
with pytest.raises(TypeError):
1253-
ax.xaxis.set_minor_formatter(matplotlib.ticker.LogLocator())
1251+
ax.xaxis.set_minor_formatter(mticker.LogLocator())
12541252

12551253

12561254
def test_majlocator_type():
12571255
fig, ax = plt.subplots()
12581256
with pytest.raises(TypeError):
1259-
ax.xaxis.set_major_locator(matplotlib.ticker.LogFormatter())
1257+
ax.xaxis.set_major_locator(mticker.LogFormatter())
12601258

12611259

12621260
def test_minlocator_type():
12631261
fig, ax = plt.subplots()
12641262
with pytest.raises(TypeError):
1265-
ax.xaxis.set_minor_locator(matplotlib.ticker.LogFormatter())
1263+
ax.xaxis.set_minor_locator(mticker.LogFormatter())
12661264

12671265

12681266
def test_minorticks_rc():

0 commit comments

Comments
 (0)