-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtests_badfish.py
38 lines (30 loc) · 1.22 KB
/
tests_badfish.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import unittest
import pandas as pd
import numpy as np
import math
import badfish as bf
class BadFish(unittest.TestCase):
def setUp(self):
self.basic_df = pd.util.testing.makeMissingDataframe(random_state=3)
self.enc_df = self.basic_df.copy()
self.enc_df.iloc[0,0] = "MISSING" #Adding Missing to column A
self.enc_df.iloc[0,1] = "MISSING" #Adding Missing to column B
self.enc_df.iloc[0,2] = -1 #Adding Missing to column C
self.enc_df.iloc[0,3] = "N/A" #Adding Missing to column D
self.enc_df.iloc[1,3] = "N/A" #Adding Missing to column D
def test_basic_counts(self):
mf = bf.MissFrame(self.basic_df)
counts = mf.counts()
self.assertEqual(0, counts['D'])
self.assertEqual(5, counts['C'])
self.assertEqual(5, counts['B'])
self.assertEqual(2, counts['A'])
def test_missing_codes_init(self):
mf = bf.MissFrame(self.enc_df, missing_codes = ["N/A", "MISSING", -1])
counts = mf.counts()
self.assertEqual(2, counts['D'])
self.assertEqual(6, counts['C'])
self.assertEqual(6, counts['B'])
self.assertEqual(3, counts['A'])
if __name__ == '__main__':
unittest.main()