9
9
from numpy .testing import assert_almost_equal , assert_array_equal
10
10
import pytest
11
11
12
- import matplotlib
13
12
import matplotlib as mpl
14
13
from matplotlib import cbook
15
14
import matplotlib .pyplot as plt
@@ -70,7 +69,7 @@ def test_view_limits(self):
70
69
"""
71
70
Test basic behavior of view limits.
72
71
"""
73
- with matplotlib .rc_context ({'axes.autolimit_mode' : 'data' }):
72
+ with mpl .rc_context ({'axes.autolimit_mode' : 'data' }):
74
73
loc = mticker .MultipleLocator (base = 3.147 )
75
74
assert_almost_equal (loc .view_limits (- 5 , 5 ), (- 5 , 5 ))
76
75
@@ -79,7 +78,7 @@ def test_view_limits_round_numbers(self):
79
78
Test that everything works properly with 'round_numbers' for auto
80
79
limit.
81
80
"""
82
- with matplotlib .rc_context ({'axes.autolimit_mode' : 'round_numbers' }):
81
+ with mpl .rc_context ({'axes.autolimit_mode' : 'round_numbers' }):
83
82
loc = mticker .MultipleLocator (base = 3.147 )
84
83
assert_almost_equal (loc .view_limits (- 4 , 4 ), (- 6.294 , 6.294 ))
85
84
@@ -130,7 +129,7 @@ def test_low_number_of_majorticks(
130
129
# This test is meant to verify the parameterization for
131
130
# test_number_of_minor_ticks
132
131
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 }):
134
133
majorsteps = [x [0 ] for x in self .majorstep_minordivisions ]
135
134
np .testing .assert_allclose (majorsteps ,
136
135
mticker .AutoLocator ()._steps )
@@ -516,7 +515,7 @@ class TestScalarFormatter:
516
515
@pytest .mark .parametrize ('unicode_minus, result' ,
517
516
[(True , "\N{MINUS SIGN} 1" ), (False , "-1" )])
518
517
def test_unicode_minus (self , unicode_minus , result ):
519
- matplotlib .rcParams ['axes.unicode_minus' ] = unicode_minus
518
+ mpl .rcParams ['axes.unicode_minus' ] = unicode_minus
520
519
assert (
521
520
plt .gca ().xaxis .get_major_formatter ().format_data_short (- 1 ).strip ()
522
521
== result )
@@ -540,7 +539,7 @@ def test_offset_value(self, left, right, offset):
540
539
541
540
@pytest .mark .parametrize ('use_offset' , use_offset_data )
542
541
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 }):
544
543
tmp_form = mticker .ScalarFormatter ()
545
544
assert use_offset == tmp_form .get_useOffset ()
546
545
@@ -618,8 +617,7 @@ class TestLogFormatterMathtext:
618
617
619
618
@pytest .mark .parametrize ('min_exponent, value, expected' , test_data )
620
619
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 }):
623
621
assert self .fmt (value ) == expected
624
622
625
623
@@ -648,7 +646,7 @@ class TestLogFormatterSciNotation:
648
646
def test_basic (self , base , value , expected ):
649
647
formatter = mticker .LogFormatterSciNotation (base = base )
650
648
formatter .sublabel = {1 , 2 , 5 , 1.2 }
651
- with matplotlib .rc_context ({'text.usetex' : False }):
649
+ with mpl .rc_context ({'text.usetex' : False }):
652
650
assert formatter (value ) == expected
653
651
654
652
@@ -1231,38 +1229,38 @@ class TestPercentFormatter:
1231
1229
def test_basic (self , xmax , decimals , symbol ,
1232
1230
x , display_range , expected ):
1233
1231
formatter = mticker .PercentFormatter (xmax , decimals , symbol )
1234
- with matplotlib .rc_context (rc = {'text.usetex' : False }):
1232
+ with mpl .rc_context (rc = {'text.usetex' : False }):
1235
1233
assert formatter .format_pct (x , display_range ) == expected
1236
1234
1237
1235
@pytest .mark .parametrize ('is_latex, usetex, expected' , latex_data )
1238
1236
def test_latex (self , is_latex , usetex , expected ):
1239
1237
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 }):
1241
1239
assert fmt .format_pct (50 , 100 ) == expected
1242
1240
1243
1241
1244
1242
def test_majformatter_type ():
1245
1243
fig , ax = plt .subplots ()
1246
1244
with pytest .raises (TypeError ):
1247
- ax .xaxis .set_major_formatter (matplotlib . ticker .LogLocator ())
1245
+ ax .xaxis .set_major_formatter (mticker .LogLocator ())
1248
1246
1249
1247
1250
1248
def test_minformatter_type ():
1251
1249
fig , ax = plt .subplots ()
1252
1250
with pytest .raises (TypeError ):
1253
- ax .xaxis .set_minor_formatter (matplotlib . ticker .LogLocator ())
1251
+ ax .xaxis .set_minor_formatter (mticker .LogLocator ())
1254
1252
1255
1253
1256
1254
def test_majlocator_type ():
1257
1255
fig , ax = plt .subplots ()
1258
1256
with pytest .raises (TypeError ):
1259
- ax .xaxis .set_major_locator (matplotlib . ticker .LogFormatter ())
1257
+ ax .xaxis .set_major_locator (mticker .LogFormatter ())
1260
1258
1261
1259
1262
1260
def test_minlocator_type ():
1263
1261
fig , ax = plt .subplots ()
1264
1262
with pytest .raises (TypeError ):
1265
- ax .xaxis .set_minor_locator (matplotlib . ticker .LogFormatter ())
1263
+ ax .xaxis .set_minor_locator (mticker .LogFormatter ())
1266
1264
1267
1265
1268
1266
def test_minorticks_rc ():
0 commit comments