|
6 | 6 | import nose.tools as nt
|
7 | 7 | import numpy.testing as nptest
|
8 | 8 | from matplotlib.testing.decorators import image_comparison, cleanup
|
| 9 | +try: |
| 10 | + from scipy import stats |
| 11 | +except: |
| 12 | + stats = None |
9 | 13 |
|
10 | 14 | from probscale import viz
|
11 | 15 | from probscale.probscale import _minimal_norm
|
12 | 16 |
|
| 17 | + |
13 | 18 | @nt.nottest
|
14 | 19 | def setup_plot_data():
|
15 | 20 | data = numpy.array([
|
@@ -466,6 +471,40 @@ def test_probplot_pp_bestfit_probax_y():
|
466 | 471 | scatter_kws=scatter_kws, line_kws=line_kws)
|
467 | 472 |
|
468 | 473 |
|
| 474 | +@image_comparison(baseline_images=['test_probplot_beta_dist_best_fit_y'], extensions=['png']) |
| 475 | +@nptest.dec.skipif(stats is None) |
| 476 | +def test_probplot_beta_dist_best_fit_y(): |
| 477 | + fig, (ax1, ax2) = plt.subplots(ncols=2) |
| 478 | + data = setup_plot_data() |
| 479 | + dist = stats.beta(3, 3) |
| 480 | + fig = viz.probplot(data, dist=dist, ax=ax1, ylabel='Beta scale', |
| 481 | + bestfit=True, otherscale='log', probax='y') |
| 482 | + ax1.set_ylim(bottom=0.5, top=98) |
| 483 | + |
| 484 | + fig = viz.probplot(data, ax=ax2, xlabel='Default (norm)', |
| 485 | + bestfit=True, otherscale='log', probax='y') |
| 486 | + ax2.set_ylim(bottom=0.5, top=98) |
| 487 | + |
| 488 | + nt.assert_true(isinstance(fig, plt.Figure)) |
| 489 | + |
| 490 | + |
| 491 | +@image_comparison(baseline_images=['test_probplot_beta_dist_best_fit_x'], extensions=['png']) |
| 492 | +@nptest.dec.skipif(stats is None) |
| 493 | +def test_probplot_beta_dist_best_fit_x(): |
| 494 | + fig, (ax1, ax2) = plt.subplots(nrows=2) |
| 495 | + data = setup_plot_data() |
| 496 | + dist = stats.beta(3, 3) |
| 497 | + fig = viz.probplot(data, dist=dist, ax=ax1, xlabel='Beta scale', |
| 498 | + bestfit=True, otherscale='log', probax='x') |
| 499 | + ax1.set_xlim(left=0.5, right=98) |
| 500 | + |
| 501 | + fig = viz.probplot(data, ax=ax2, xlabel='Default (norm)', |
| 502 | + bestfit=True, otherscale='log', probax='x') |
| 503 | + ax2.set_xlim(left=0.5, right=98) |
| 504 | + |
| 505 | + nt.assert_true(isinstance(fig, plt.Figure)) |
| 506 | + |
| 507 | + |
469 | 508 | @cleanup
|
470 | 509 | def test_probplot_test_results():
|
471 | 510 | fig, ax = plt.subplots()
|
|
0 commit comments