Skip to content

Commit

Permalink
Merge branch 'v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffckerr committed Sep 15, 2023
2 parents 90c234b + 19bd80e commit 127cb21
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
19 changes: 14 additions & 5 deletions binomialbias/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def __init__(self, n=20, n_e=10, n_a=7, f_e=None, f_a=None, one_sided=True,
B.display()
"""
# Handle deprecations
expected = kwargs.pop('expected', n_e)
actual = kwargs.pop('actual', n_a)
expected = kwargs.pop('expected', None) or n_e
actual = kwargs.pop('actual', None) or n_a
if 0 < expected < 1: f_e = expected # Treat as fractions
if 0 < actual < 1: f_a = actual

Expand Down Expand Up @@ -372,9 +372,18 @@ def plot(self, dist_color='cornflowerblue', cdf_color='darkblue', ci_color='k',
return fig


def plot_bias(n=20, expected=10, actual=7, show=True, letters=True, display=True, **kwargs):
""" Script to simply plot the bias without creating a class instance; see BinomialBias for arguments """
B = BinomialBias(n=n, expected=expected, actual=actual)
def plot_bias(show=True, letters=True, display=True, **kwargs):
"""
Script to simply plot the bias without creating a class instance; see BinomialBias for arguments
**Example**::
import binomialbias as bb
bb.plot_bias(n=20, n_e=10, n_a=7)
"""
bb_keys = ['n', 'n_e', 'n_a', 'f_e', 'f_a', 'expected', 'actual']
bb_kwargs = {k:kwargs.pop(k) for k in bb_keys if k in kwargs}
B = BinomialBias(**bb_kwargs)
B.plot(show=show, letters=letters, **kwargs)
if display:
B.display()
Expand Down
14 changes: 11 additions & 3 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'''
"""
Simple tests of plotting
'''
"""

import sciris as sc
import binomialbias as bb


def test_plotting(show=False):
''' Test several different plotting options '''
""" Test several different plotting options """

sc.options(interactive=show)

Expand All @@ -25,7 +25,15 @@ def test_plotting(show=False):
return out


def test_plot_bias(show=False):
""" Test function example """
sc.options(interactive=show)
B = bb.plot_bias(n=20, n_e=10, n_a=7, show=show)
return B


if __name__ == '__main__':
out = test_plotting(show=True)
B = test_plot_bias(show=True)


0 comments on commit 127cb21

Please sign in to comment.