1
- import matplotlib
1
+ import matplotlib
2
2
matplotlib .use ('agg' )
3
3
4
4
import numpy as np
@@ -24,12 +24,12 @@ def setup_plot_data():
24
24
return data
25
25
26
26
27
- @cleanup
28
27
class Test__check_ax_obj (object ):
29
28
@nt .raises (ValueError )
30
29
def test_bad_value (self ):
31
30
viz ._check_ax_obj ('junk' )
32
31
32
+ @cleanup
33
33
def test_with_ax (self ):
34
34
fig , ax = plt .subplots ()
35
35
fig1 , ax1 = viz ._check_ax_obj (ax )
@@ -38,15 +38,16 @@ def test_with_ax(self):
38
38
nt .assert_true (ax1 is ax )
39
39
nt .assert_true (fig1 is fig )
40
40
41
+ @cleanup
41
42
def test_with_None (self ):
42
43
fig1 , ax1 = viz ._check_ax_obj (None )
43
44
nt .assert_true (isinstance (ax1 , plt .Axes ))
44
45
nt .assert_true (isinstance (fig1 , plt .Figure ))
45
46
46
47
47
- class Test__check_fig_arg (object ):
48
+ class Test__check_fit_arg (object ):
48
49
@nt .raises (ValueError )
49
- def test_bad_value (self ):
50
+ def test_bad_fitarg (self ):
50
51
viz ._check_fit_arg ('junk' , 'fitprobs' )
51
52
52
53
def test_x (self ):
@@ -67,8 +68,8 @@ def test_None(self):
67
68
68
69
69
70
class Test__check_ax_name (object ):
70
- @nt .raises ( ValueError )
71
- def test_bad_value (self ):
71
+ @nt .raises
72
+ def test_bad_name (self ):
72
73
viz ._check_fit_arg ('junk' , 'axname' )
73
74
74
75
def test_x (self ):
@@ -330,3 +331,64 @@ def test_probplot_pp_bestfit():
330
331
fig = viz .probplot (data , ax = ax , axtype = 'pp' , otherscale = 'linear' ,
331
332
xlabel = 'test x' , bestfit = True , ylabel = 'test y' ,
332
333
scatter_kws = scatter_kws , line_kws = line_kws )
334
+
335
+
336
+ @image_comparison (baseline_images = ['test_probplot_prob_probax_y' ], extensions = ['png' ])
337
+ def test_probplot_prob_probax_y ():
338
+ fig , ax = plt .subplots ()
339
+ data = setup_plot_data ()
340
+ fig = viz .probplot (data , ax = ax , xlabel = 'Test xlabel' , otherscale = 'log' , probax = 'y' )
341
+ nt .assert_true (isinstance (fig , plt .Figure ))
342
+
343
+
344
+ @image_comparison (baseline_images = ['test_probplot_qq_probax_y' ], extensions = ['png' ])
345
+ def test_probplot_qq_probax_y ():
346
+ fig , ax = plt .subplots ()
347
+ data = setup_plot_data ()
348
+ fig = viz .probplot (data , ax = ax , axtype = 'qq' , ylabel = 'Test label' , probax = 'y' ,
349
+ otherscale = 'log' , scatter_kws = dict (color = 'r' ))
350
+
351
+
352
+ @image_comparison (baseline_images = ['test_probplot_pp_probax_y' ], extensions = ['png' ])
353
+ def test_probplot_pp_probax_y ():
354
+ fig , ax = plt .subplots ()
355
+ data = setup_plot_data ()
356
+ scatter_kws = dict (color = 'b' , linestyle = '--' , markeredgecolor = 'g' , markerfacecolor = 'none' )
357
+ fig = viz .probplot (data , ax = ax , axtype = 'pp' , otherscale = 'linear' , probax = 'y' ,
358
+ xlabel = 'test x' , ylabel = 'test y' , scatter_kws = scatter_kws )
359
+
360
+
361
+ @image_comparison (baseline_images = ['test_probplot_prob_bestfit_probax_y' ], extensions = ['png' ])
362
+ def test_probplot_prob_bestfit_probax_y ():
363
+ fig , ax = plt .subplots ()
364
+ data = setup_plot_data ()
365
+ fig = viz .probplot (data , ax = ax , xlabel = 'Test xlabel' , bestfit = True , otherscale = 'log' , probax = 'y' )
366
+ nt .assert_true (isinstance (fig , plt .Figure ))
367
+
368
+
369
+ @image_comparison (baseline_images = ['test_probplot_qq_bestfit_probax_y' ], extensions = ['png' ])
370
+ def test_probplot_qq_bestfit_probax_y ():
371
+ fig , ax = plt .subplots ()
372
+ data = setup_plot_data ()
373
+ fig = viz .probplot (data , ax = ax , axtype = 'qq' , bestfit = True , ylabel = 'Test label' , otherscale = 'log' , probax = 'y' )
374
+
375
+
376
+ @image_comparison (baseline_images = ['test_probplot_pp_bestfit_probax_y' ], extensions = ['png' ])
377
+ def test_probplot_pp_bestfit_probax_y ():
378
+ fig , ax = plt .subplots ()
379
+ data = setup_plot_data ()
380
+ scatter_kws = {'marker' : 's' , 'color' : 'red' }
381
+ line_kws = {'linestyle' : '--' , 'linewidth' : 3 }
382
+ fig = viz .probplot (data , ax = ax , axtype = 'pp' , otherscale = 'linear' , probax = 'y' ,
383
+ xlabel = 'test x' , bestfit = True , ylabel = 'test y' ,
384
+ scatter_kws = scatter_kws , line_kws = line_kws )
385
+
386
+
387
+ def test_probplot_test_results ():
388
+ fig , ax = plt .subplots ()
389
+ data = setup_plot_data ()
390
+ fig , results = viz .probplot (data , return_results = True )
391
+
392
+ nt .assert_true (isinstance (results , dict ))
393
+ known_keys = sorted (['q' , 'x' , 'y' , 'xhat' , 'yhat' , 'res' ])
394
+ nt .assert_list_equal (sorted (list (results .keys ())), known_keys )
0 commit comments