Beispiel #1
0
 def test_update_map(self):
     data = ['b', 'd', 'e', np.inf]
     old_map = [('a', 0), ('d', 1)]
     exp = [('inf', -2), ('a', 0), ('d', 1),
            ('b', 2), ('e', 3)]
     act = cat.map_categories(data, old_map)
     self.assertListEqual(sorted(act), sorted(exp))
Beispiel #2
0
    def test_map_data_mixed(self):
        data = ['A', 'A', np.nan, 'B', -np.inf, 3.14, np.inf]
        exp = [('nan', -1), ('3.14', 0), ('A', 1), ('B', 2), ('-inf', -3),
               ('inf', -2)]

        act = cat.map_categories(data)
        self.assertListEqual(sorted(act), sorted(exp))
Beispiel #3
0
    def test_map_data_mixed(self):
        data = ['A', 'A', np.nan, 'B', -np.inf, 3.14, np.inf]
        exp = [('nan', -1), ('3.14', 0),
               ('A', 1), ('B', 2), ('-inf', -3), ('inf', -2)]

        act = cat.map_categories(data)
        self.assertListEqual(sorted(act), sorted(exp))
Beispiel #4
0
 def test_map_data_basic(self):
     data = ['a', 'b', 'b', 'a', 'a', 'c', 'c', 'c']
     exp = [('a', 0), ('b', 1), ('c', 2)]
     act = cat.map_categories(data)
     self.assertListEqual(sorted(act), sorted(exp))
Beispiel #5
0
 def test_map_data(self):
     act = cat.map_categories("hello world")
     exp = [("hello world", 0)]
     self.assertListEqual(act, exp)
Beispiel #6
0
 def test_map_unicode(self):
     act = cat.map_categories("Здравствуйте мир")
     exp = [("Здравствуйте мир", 0)]
     self.assertListEqual(act, exp)
Beispiel #7
0
 def test_update_map(self):
     data = ['b', 'd', 'e', np.inf]
     old_map = [('a', 0), ('d', 1)]
     exp = [('inf', -2), ('a', 0), ('d', 1), ('b', 2), ('e', 3)]
     act = cat.map_categories(data, old_map)
     self.assertListEqual(sorted(act), sorted(exp))
Beispiel #8
0
 def test_map_data_basic(self):
     data = ['a', 'b', 'b', 'a', 'a', 'c', 'c', 'c']
     exp = [('a', 0), ('b', 1), ('c', 2)]
     act = cat.map_categories(data)
     self.assertListEqual(sorted(act), sorted(exp))
Beispiel #9
0
 def test_map_data(self):
     act = cat.map_categories("hello world")
     exp = [("hello world", 0)]
     self.assertListEqual(act, exp)
Beispiel #10
0
 def test_map_unicode(self):
     act = cat.map_categories("Здравствуйте мир")
     exp = [("Здравствуйте мир", 0)]
     self.assertListEqual(act, exp)