@@ -1806,25 +1806,23 @@ def test_hist_zorder(histtype, zorder):
1806
1806
assert patch .get_zorder () == zorder
1807
1807
1808
1808
1809
- @check_figures_equal ()
1809
+ @check_figures_equal (extensions = [ 'png' ] )
1810
1810
def test_stairs (fig_test , fig_ref ):
1811
1811
import matplotlib .lines as mlines
1812
1812
y = np .array ([6 , 14 , 32 , 37 , 48 , 32 , 21 , 4 ]) # hist
1813
1813
x = np .array ([1. , 2. , 3. , 4. , 5. , 6. , 7. , 8. , 9. ]) # bins
1814
1814
1815
- fig_test , test_axes = plt .subplots (3 , 2 )
1816
- test_axes = test_axes .flatten ()
1815
+ test_axes = fig_test .subplots (3 , 2 ).flatten ()
1817
1816
test_axes [0 ].stairs (y , x , baseline = None )
1818
1817
test_axes [1 ].stairs (y , x , baseline = None , orientation = 'horizontal' )
1819
1818
test_axes [2 ].stairs (y , x )
1820
1819
test_axes [3 ].stairs (y , x , orientation = 'horizontal' )
1821
1820
test_axes [4 ].stairs (y , x )
1822
1821
test_axes [4 ].semilogy ()
1823
1822
test_axes [5 ].stairs (y , x , orientation = 'horizontal' )
1824
- test_axes [5 ].semilogy ()
1823
+ test_axes [5 ].semilogx ()
1825
1824
1826
- fig_ref , ref_axes = plt .subplots (3 , 2 )
1827
- ref_axes = ref_axes .flatten ()
1825
+ ref_axes = fig_ref .subplots (3 , 2 ).flatten ()
1828
1826
ref_axes [0 ].plot (x , np .append (y , y [- 1 ]), drawstyle = 'steps-post' )
1829
1827
ref_axes [1 ].plot (np .append (y [0 ], y ), x , drawstyle = 'steps-post' )
1830
1828
@@ -1849,22 +1847,20 @@ def test_stairs(fig_test, fig_ref):
1849
1847
ref_axes [5 ].semilogx ()
1850
1848
1851
1849
1852
- @check_figures_equal ()
1850
+ @check_figures_equal (extensions = [ 'png' ] )
1853
1851
def test_stairs_fill (fig_test , fig_ref ):
1854
1852
h , bins = [1 , 2 , 3 , 4 , 2 ], [0 , 1 , 2 , 3 , 4 , 5 ]
1855
1853
bs = - 2
1856
1854
# Test
1857
- fig_test , test_axes = plt .subplots (2 , 2 )
1858
- test_axes = test_axes .flatten ()
1855
+ test_axes = fig_test .subplots (2 , 2 ).flatten ()
1859
1856
test_axes [0 ].stairs (h , bins , fill = True )
1860
1857
test_axes [1 ].stairs (h , bins , orientation = 'horizontal' , fill = True )
1861
1858
test_axes [2 ].stairs (h , bins , baseline = bs , fill = True )
1862
1859
test_axes [3 ].stairs (h , bins , baseline = bs , orientation = 'horizontal' ,
1863
- fill = True )
1860
+ fill = True )
1864
1861
1865
1862
# # Ref
1866
- fig_ref , ref_axes = plt .subplots (2 , 2 )
1867
- ref_axes = ref_axes .flatten ()
1863
+ ref_axes = fig_ref .subplots (2 , 2 ).flatten ()
1868
1864
ref_axes [0 ].fill_between (bins , np .append (h , h [- 1 ]), step = 'post' )
1869
1865
ref_axes [0 ].set_ylim (0 , None )
1870
1866
ref_axes [1 ].fill_betweenx (bins , np .append (h , h [- 1 ]), step = 'post' )
@@ -1877,10 +1873,10 @@ def test_stairs_fill(fig_test, fig_ref):
1877
1873
ref_axes [3 ].set_xlim (bs , None )
1878
1874
1879
1875
1880
- @check_figures_equal ()
1876
+ @check_figures_equal (extensions = [ 'png' ] )
1881
1877
def test_stairs_update (fig_test , fig_ref ):
1882
1878
# Test
1883
- fig_test , test_ax = plt . subplots ()
1879
+ test_ax = fig_test . add_subplot ()
1884
1880
h = test_ax .stairs ([1 , 2 , 3 ])
1885
1881
h .set_values ([3 , 2 , 1 ])
1886
1882
h .set_edges (np .arange (4 )+ 2 )
@@ -1893,30 +1889,30 @@ def test_stairs_update(fig_test, fig_ref):
1893
1889
assert h .get_baseline () == - 2
1894
1890
1895
1891
# # Ref
1896
- fig_ref , ref_ax = plt . subplots ()
1892
+ ref_ax = fig_ref . add_subplot ()
1897
1893
h = ref_ax .stairs ([1 , 2 , 3 ], baseline = - 2 )
1898
1894
1899
1895
1900
- @pytest .mark .xfail
1901
1896
def test_stairs_invalid_nan ():
1902
- plt .stairs ([1 , 2 ], [0 , np .nan , 1 ])
1897
+ with pytest .raises (ValueError , match = 'Nan values in "edges"' ):
1898
+ plt .stairs ([1 , 2 ], [0 , np .nan , 1 ])
1903
1899
1904
1900
1905
- @pytest .mark .xfail
1906
1901
def test_stairs_invalid_mismatch ():
1907
- plt .stairs ([1 , 2 ], [0 , 1 ])
1902
+ with pytest .raises (ValueError , match = 'Size mismatch' ):
1903
+ plt .stairs ([1 , 2 ], [0 , 1 ])
1908
1904
1909
1905
1910
- @pytest .mark .xfail
1911
1906
def test_stairs_invalid_update ():
1912
1907
h = plt .stairs ([1 , 2 ], [0 , 1 , 2 ])
1913
- h .set_edges ([1 , np .nan , 2 ])
1908
+ with pytest .raises (ValueError , match = 'Nan values in "edges"' ):
1909
+ h .set_edges ([1 , np .nan , 2 ])
1914
1910
1915
1911
1916
- @pytest .mark .xfail
1917
1912
def test_stairs_invalid_update2 ():
1918
1913
h = plt .stairs ([1 , 2 ], [0 , 1 , 2 ])
1919
- h .set_edges (np .arange (5 ))
1914
+ with pytest .raises (ValueError , match = 'Size mismatch' ):
1915
+ h .set_edges (np .arange (5 ))
1920
1916
1921
1917
1922
1918
@image_comparison (['test_stairs_options.png' ], remove_text = True )
0 commit comments