Пример #1
0
 def test_NFD_array(self):
     store = [{'array': np.array([1, 2, 3])}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('array_[0]', [1]),
                                               ('array_[1]', [2]),
                                               ('array_[2]', [3])])
     assert result == correct_result
Пример #2
0
 def test_NFD_array3(self):
     store = [{'array': np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]])}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('array_[0 0]', [1]), ('array_[1 0]', [3]), ('array_[2 0]', [5]),
                                               ('array_[3 0]', [7]), ('array_[4 0]', [9]), ('array_[5 0]', [11]),
                                               ('array_[0 1]', [2]), ('array_[1 1]', [4]), ('array_[2 1]', [6]),
                                               ('array_[3 1]', [8]), ('array_[4 1]', [10]), ('array_[5 1]', [12])])
     assert result == correct_result
Пример #3
0
 def test_NFD_array2(self):
     store = [{'array': np.array([[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]])}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('array_[0 0]', [1]), ('array_[1 0]', [7]), ('array_[0 1]', [2]),
                                               ('array_[1 1]', [8]), ('array_[0 2]', [3]), ('array_[1 2]', [9]),
                                               ('array_[0 3]', [4]), ('array_[1 3]', [10]), ('array_[0 4]', [5]),
                                               ('array_[1 4]', [11]), ('array_[0 5]', [6]), ('array_[1 5]', [12])])
     assert result == correct_result
Пример #4
0
 def test_NFD_dict2(self):
     store = [{'dict': {1: [1, 2, 3], 2: [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]]}}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('dict_1_[0]', [1]), ('dict_1_[1]', [2]), ('dict_1_[2]', [3]),
                                               ('dict_2_[0 0]', [1]), ('dict_2_[1 0]', [12]), ('dict_2_[0 1]', [2]),
                                               ('dict_2_[1 1]', [13]), ('dict_2_[0 2]', [3]), ('dict_2_[1 2]', [14]),
                                               ('dict_2_[0 3]', [4]), ('dict_2_[1 3]', [15]), ('dict_2_[0 4]', [5]),
                                               ('dict_2_[1 4]', [16]), ('dict_2_[0 5]', [6]), ('dict_2_[1 5]', [17]),
                                               ('dict_2_[0 6]', [7]), ('dict_2_[1 6]', [18]), ('dict_2_[0 7]', [8]),
                                               ('dict_2_[1 7]', [19]), ('dict_2_[0 8]', [9]), ('dict_2_[1 8]', [20]),
                                               ('dict_2_[0 9]', [10]), ('dict_2_[1 9]', [21]), ('dict_2_[ 0 10]', [11]),
                                               ('dict_2_[ 1 10]', [22])])
     assert result == correct_result
Пример #5
0
 def test_NFD_dict3(self):
     store = [{'dict': {1: {3: "a"}, 2: "b"}}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('dict_1_3', ["'a'"]), ('dict_2', ["'b'"])])
     assert result == correct_result
Пример #6
0
 def test_NFD_num2(self):
     store = [{'num': 23.6}, {'num': 29}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('num', ['23.6', '29'])])
     assert result == correct_result
Пример #7
0
 def test_NFD_list1(self):
     store = [{'list': [1, 2, 3, 4, 5, 6]}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('list_[0]', [1]), ('list_[1]', [2]), ('list_[2]', [3]),
                                               ('list_[3]', [4]), ('list_[4]', [5]), ('list_[5]', [6])])
     assert result == correct_result
Пример #8
0
 def test_NFD_string(self):
     store = [{'string': 'string'}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict([('string', ["'string'"])])
     assert result == correct_result
Пример #9
0
 def test_NFD_none2(self):
     store = [{}]
     result = outputting.newFlatDict(store)
     correct_result = collections.OrderedDict()
     assert result == correct_result