Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fba02de

Browse files
committed
Remove a redundant import in test_ticker.
1 parent b72ac36 commit fba02de

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

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)