Skip to content

Commit

Permalink
better naming for last 2 digits generation func
Browse files Browse the repository at this point in the history
  • Loading branch information
milcent committed Apr 17, 2021
1 parent 8add096 commit 69edd11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions benford/expected.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class LastTwo(DataFrame):
def __init__(self, num=False, plot=True, save_plot=None, save_plot_kwargs=None):
exp = array([1 / 99.] * 100)
DataFrame.__init__(self, {'Expected': exp,
'Last_2_Dig': _lt_(num=num)})
'Last_2_Dig': _gen_last_2_digs_(num=num)})
self.set_index('Last_2_Dig', inplace=True)
if plot:
plot_expected(self, -2, save_plot=save_plot,
Expand All @@ -114,7 +114,7 @@ def _test_(digs):
return LastTwo(num=True, plot=False)


def _lt_(num=False):
def _gen_last_2_digs_(num=False):
"""Creates an array with the possible last two digits
Args:
Expand All @@ -125,10 +125,10 @@ def _lt_(num=False):
Array of ints or str, in any case representing all 100 possible
combinations of last two digits
"""
n = arange(0, 100)
if num:
n = arange(0, 100)
else:
n = arange(0, 100).astype(str)
n[:10] = array(['00', '01', '02', '03', '04', '05',
'06', '07', '08', '09'])
return n
n = n.astype(str)
n[:10] = array(['00', '01', '02', '03', '04', '05',
'06', '07', '08', '09'])
return n
6 changes: 3 additions & 3 deletions tests/test_expected.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def test__minus_2(self):
assert len(f1d) == 100


class Test__lt_():
class Test_gen_last_2_digs_():

def test_num_False(self):
lt = ex._lt_()
lt = ex._gen_last_2_digs_()
assert len(lt) == 100
assert lt.dtype == '<U21'

def test_num_True(self):
lt = ex._lt_(num=True)
lt = ex._gen_last_2_digs_(num=True)
assert len(lt) == 100
assert lt.dtype == 'int'

0 comments on commit 69edd11

Please sign in to comment.