Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)))
Exemplo n.º 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')
Exemplo n.º 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)))
Exemplo n.º 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')
Exemplo n.º 8
0
 def test_getDataEntry_broken_path(self):
     data = None
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(ValueError, dataStructure.getDataEntry, data,
                       ['a', 'b'], [Exception(), ...])
Exemplo n.º 9
0
 def test_getDataEntry_empty_path(self):
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(ValueError, dataStructure.getDataEntry, [], [], [])
Exemplo n.º 10
0
 def test_getitem_nonexisting_entry(self):
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(ValueError, dataStructure.__getitem__,
                       'nonexisitingEntry')
Exemplo n.º 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)))
Exemplo n.º 12
0
 def test_setitem_non_existing_entry(self):
     dataStructure = DataStructure(self.dataManager, 5)
     self.assertRaises(KeyError, dataStructure.__setitem__, 'noEntry',
                       np.ndarray((1, 2)))
Exemplo n.º 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)
Exemplo n.º 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)))