Skip to content

Commit dc38a9a

Browse files
committed
vertical probscale tests and images
1 parent e890210 commit dc38a9a

File tree

7 files changed

+68
-6
lines changed

7 files changed

+68
-6
lines changed

probscale/tests/test_probscale/test_viz.py

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import matplotlib
1+
import matplotlib
22
matplotlib.use('agg')
33

44
import numpy as np
@@ -24,12 +24,12 @@ def setup_plot_data():
2424
return data
2525

2626

27-
@cleanup
2827
class Test__check_ax_obj(object):
2928
@nt.raises(ValueError)
3029
def test_bad_value(self):
3130
viz._check_ax_obj('junk')
3231

32+
@cleanup
3333
def test_with_ax(self):
3434
fig, ax = plt.subplots()
3535
fig1, ax1 = viz._check_ax_obj(ax)
@@ -38,15 +38,16 @@ def test_with_ax(self):
3838
nt.assert_true(ax1 is ax)
3939
nt.assert_true(fig1 is fig)
4040

41+
@cleanup
4142
def test_with_None(self):
4243
fig1, ax1 = viz._check_ax_obj(None)
4344
nt.assert_true(isinstance(ax1, plt.Axes))
4445
nt.assert_true(isinstance(fig1, plt.Figure))
4546

4647

47-
class Test__check_fig_arg(object):
48+
class Test__check_fit_arg(object):
4849
@nt.raises(ValueError)
49-
def test_bad_value(self):
50+
def test_bad_fitarg(self):
5051
viz._check_fit_arg('junk', 'fitprobs')
5152

5253
def test_x(self):
@@ -67,8 +68,8 @@ def test_None(self):
6768

6869

6970
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):
7273
viz._check_fit_arg('junk', 'axname')
7374

7475
def test_x(self):
@@ -330,3 +331,64 @@ def test_probplot_pp_bestfit():
330331
fig = viz.probplot(data, ax=ax, axtype='pp', otherscale='linear',
331332
xlabel='test x', bestfit=True, ylabel='test y',
332333
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

Comments
 (0)