Skip to content

Commit 761e175

Browse files
committed
tests for custom-dist prob plots
1 parent 2d735ff commit 761e175

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Loading
Loading

probscale/tests/test_viz.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
import nose.tools as nt
77
import numpy.testing as nptest
88
from matplotlib.testing.decorators import image_comparison, cleanup
9+
try:
10+
from scipy import stats
11+
except:
12+
stats = None
913

1014
from probscale import viz
1115
from probscale.probscale import _minimal_norm
1216

17+
1318
@nt.nottest
1419
def setup_plot_data():
1520
data = numpy.array([
@@ -466,6 +471,40 @@ def test_probplot_pp_bestfit_probax_y():
466471
scatter_kws=scatter_kws, line_kws=line_kws)
467472

468473

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+
469508
@cleanup
470509
def test_probplot_test_results():
471510
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)