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 ):
@@ -270,6 +271,17 @@ def test_linlog(self):
270
271
)
271
272
272
273
274
+ class Test__check_ax_type (object ):
275
+ @nt .raises (ValueError )
276
+ def test_bad_value (self ):
277
+ viz ._check_ax_type ("JUNK" )
278
+
279
+ def test_upper (self ):
280
+ nt .assert_equal ('pp' , viz ._check_ax_type ('PP' ))
281
+ nt .assert_equal ('qq' , viz ._check_ax_type ('QQ' ))
282
+ nt .assert_equal ('prob' , viz ._check_ax_type ('ProB' ))
283
+
284
+
273
285
@image_comparison (baseline_images = ['test_probplot_prob' ], extensions = ['png' ])
274
286
def test_probplot_prob ():
275
287
fig , ax = plt .subplots ()
@@ -319,3 +331,65 @@ def test_probplot_pp_bestfit():
319
331
fig = viz .probplot (data , ax = ax , axtype = 'pp' , otherscale = 'linear' ,
320
332
xlabel = 'test x' , bestfit = True , ylabel = 'test y' ,
321
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
+ @cleanup
388
+ def test_probplot_test_results ():
389
+ fig , ax = plt .subplots ()
390
+ data = setup_plot_data ()
391
+ fig , results = viz .probplot (data , return_results = True )
392
+
393
+ nt .assert_true (isinstance (results , dict ))
394
+ known_keys = sorted (['q' , 'x' , 'y' , 'xhat' , 'yhat' , 'res' ])
395
+ nt .assert_list_equal (sorted (list (results .keys ())), known_keys )
0 commit comments