Skip to content

Commit

Permalink
add dataframe to unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed Aug 1, 2022
1 parent db51004 commit 9ed83b2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions benfordslaw/tests/test_benfordslaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ def test_benfordslaw(self):

# TEST 4: check percentages
assert np.all(out['percentage_emp'][:,1]==[31.64521544487969, 16.508114157806382, 12.479015109121432, 9.820928931169558, 7.862339115836598, 6.3794068270845, 5.8477895914941245, 4.616675993284835, 4.8405148293228875])

def test_dataframe(self):
bl = benfordslaw()
df = bl.import_example()
Iloc = df['candidate']=='Donald Trump'
X = df['votes'].loc[Iloc]
results = bl.fit(X)
np.all(np.isin([*results.keys()], ['P', 't', 'percentage_emp', 'P_significant']))
assert np.all(results['percentage_emp'][:,1]==[31.64521544487969, 16.508114157806382, 12.479015109121432, 9.820928931169558, 7.862339115836598, 6.3794068270845, 5.8477895914941245, 4.616675993284835, 4.8405148293228875])

0 comments on commit 9ed83b2

Please sign in to comment.