예제 #1
0
 def test_missing_value(self):
     data = iter([['a','b','c'],['1','2', ''],['', '5', '6']])
     type_list = ['NOMINAL', 'INTEGER']
     relation_name = "testing"
     selected_attrs = ['a', 'c']
     result = data_to_dict(data, type_list, relation_name, selected_attrs)
     self.assertEqual(result['relation'], 'testing')
     self.assertEqual(result['attributes'], [(u'a', [u'1']),
                                             (u'c', 'INTEGER')])
     self.assertEqual(result['data'], [[u'1', None], [None, u'6']])
예제 #2
0
 def test_missing_value(self):
     data = iter([['a', 'b', 'c'], ['1', '2', ''], ['', '5', '6']])
     type_list = ['NOMINAL', 'INTEGER']
     relation_name = "testing"
     selected_attrs = ['a', 'c']
     result = data_to_dict(data, type_list, relation_name, selected_attrs)
     self.assertEqual(result['relation'], 'testing')
     self.assertEqual(result['attributes'], [(u'a', [u'1']),
                                             (u'c', 'INTEGER')])
     self.assertEqual(result['data'], [[u'1', None], [None, u'6']])
예제 #3
0
 def test_no_attributes_selected(self):
     data = iter([['a','b','c'],['1','2', '3'],['4', '5', '6']])
     type_list = ['NOMINAL', 'STRING', 'INTEGER']
     relation_name = "testing"
     selected_attrs = []
     result = data_to_dict(data, type_list, relation_name, selected_attrs)
     self.assertEqual(result['relation'], 'testing')
     self.assertEqual(result['attributes'], [(u'a', [u'1', u'4']),
         (u'b', 'STRING'), (u'c', 'INTEGER')])
     self.assertEqual(result['data'], [[u'1', u'2', u'3'], [u'4', u'5',
                                          u'6']])
예제 #4
0
    def test_unicode(self):
        data = iter([['a','moño','cám'],['1','2', 'maña'],['', '5', 'cán']])
        type_list = ['NOMINAL', 'INTEGER', 'STRING']
        relation_name = "testing"
        selected_attrs = ['a', 'moño', 'cám']
        result = data_to_dict(data, type_list, relation_name, selected_attrs)

        self.assertEqual(result['relation'], 'testing')
        self.assertEqual(result['attributes'], [(u'a', [u'1']),
            (u'moño', 'INTEGER'), (u'cám', 'STRING')])
        self.assertEqual(result['data'], [[u'1', u'2', u'maña'],
                         [None, u'5', u'cán']])
예제 #5
0
 def test_no_attributes_selected(self):
     data = iter([['a', 'b', 'c'], ['1', '2', '3'], ['4', '5', '6']])
     type_list = ['NOMINAL', 'STRING', 'INTEGER']
     relation_name = "testing"
     selected_attrs = []
     result = data_to_dict(data, type_list, relation_name, selected_attrs)
     self.assertEqual(result['relation'], 'testing')
     self.assertEqual(result['attributes'], [(u'a', [u'1', u'4']),
                                             (u'b', 'STRING'),
                                             (u'c', 'INTEGER')])
     self.assertEqual(result['data'],
                      [[u'1', u'2', u'3'], [u'4', u'5', u'6']])
예제 #6
0
    def test_unicode(self):
        data = iter([['a', 'moño', 'cám'], ['1', '2', 'maña'],
                     ['', '5', 'cán']])
        type_list = ['NOMINAL', 'INTEGER', 'STRING']
        relation_name = "testing"
        selected_attrs = ['a', 'moño', 'cám']
        result = data_to_dict(data, type_list, relation_name, selected_attrs)

        self.assertEqual(result['relation'], 'testing')
        self.assertEqual(result['attributes'], [(u'a', [u'1']),
                                                (u'moño', 'INTEGER'),
                                                (u'cám', 'STRING')])
        self.assertEqual(result['data'],
                         [[u'1', u'2', u'maña'], [None, u'5', u'cán']])