示例#1
0
    def test_setitem_non_ndarray(self):
        dataStructure = DataStructure(self.dataManager, 5)
        dataEntry = DataEntry('parameters', 3)
        dataStructure.createEntry('parameters', dataEntry)

        self.assertRaises(ValueError, dataStructure.__setitem__, 'parameters',
                          None)
示例#2
0
    def test_createEntry_twice(self):
        dataStructure = DataStructure(self.dataManager, 5)

        dataEntry = DataEntry('parameters', 3)
        dataStructure.createEntry('parameters', dataEntry)

        self.assertRaises(ValueError, dataStructure.createEntry, 'parameters',
                          dataEntry)
示例#3
0
    def test_len(self):
        dataStructure = DataStructure(self.dataManager, 5)
        self.assertEqual(len(dataStructure), 0)

        dataEntry = DataEntry('parameters', 3)
        dataStructure.createEntry('parameters', dataEntry)

        self.assertEqual(len(dataStructure), 1)
示例#4
0
    def test_setDataEntry_invalid_data_shape(self):
        dataStructure = DataStructure(self.dataManager, 5)
        data = None
        self.assertRaises(ValueError, dataStructure.setDataEntry, data, ['a'],
                          [slice(0, 5)], np.ndarray((1, 2)))

        self.assertRaises(ValueError, dataStructure.setDataEntry, data, ['a'],
                          [3], np.ndarray((2, 1)))
示例#5
0
    def test_getitem_broken_alias(self):
        brokenAlias = DataAlias('brokenAlias',
                                [('brokenAliasEntry', slice(0, 2))], 0)

        dataStructure = DataStructure(self.dataManager, 5)
        dataStructure.createAlias('brokenAliasEntry', Exception())
        dataStructure.createAlias('brokenAlias', brokenAlias)

        self.assertRaises(ValueError, dataStructure.__getitem__, 'brokenAlias')
示例#6
0
 def test_setDataEntry_empty_path(self):
     dataStructure = DataStructure(self.dataManager, 5)
     data = None
     self.assertRaises(ValueError, dataStructure.setDataEntry, data, [], [],
                       np.ndarray((1, 2)))
示例#7
0
 def test_getDataEntry_invalid_indices_type(self):
     dataStructure = DataStructure(self.dataManager, 5)
     dataStructure.createEntry('parameters', DataEntry('parameters', 3))
     data = None
     self.assertRaises(ValueError, dataStructure.getDataEntry, data,
                       ['parameters'], 'x')
示例#8
0
 def test_getDataEntry_broken_path(self):
     data = None
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(ValueError, dataStructure.getDataEntry, data,
                       ['a', 'b'], [Exception(), ...])
示例#9
0
 def test_getDataEntry_empty_path(self):
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(ValueError, dataStructure.getDataEntry, [], [], [])
示例#10
0
 def test_getitem_nonexisting_entry(self):
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(ValueError, dataStructure.__getitem__,
                       'nonexisitingEntry')
示例#11
0
 def test_setitem_invalid_shape(self):
     dataStructure = DataStructure(self.dataManager, 5)
     dataStructure.createEntry('parameters', DataEntry('parameters', 3))
     self.assertRaises(ValueError, dataStructure.__setitem__, 'parameters',
                       np.ndarray((1, 2)))
示例#12
0
 def test_setitem_non_existing_entry(self):
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(KeyError, dataStructure.__setitem__, 'noEntry',
                       np.ndarray((1, 2)))
示例#13
0
 def test_contains(self):
     dataStructure = DataStructure(self.dataManager, 5)
     dataEntry = DataEntry('parameters', 3)
     dataStructure.createEntry('parameters', dataEntry)
     self.assertEqual('parameters' in dataStructure, True)
     self.assertEqual('praamteres' in dataStructure, False)
示例#14
0
 def test_setDataEntry_invalid_indice_type(self):
     dataStructure = DataStructure(self.dataManager, 5)
     data = None
     self.assertRaises(ValueError, dataStructure.setDataEntry, data, ['a'],
                       [Exception()], np.ndarray((2, 1)))