Beispiel #1
0
 def test_init_unknown(self):
     d = dict(id=0, a=1, b=2, c=3, d='unknown')
     s = pe.Shot(**d)
     # print(dict(s))
     self.assertEqual(len(s), 4)
     s = pe.Shot(d)
     # print(dict(s))
     self.assertEqual(len(s), 4)
Beispiel #2
0
    def test_merge(self):
        ss = self.shotseries
        ss.merge([self.createshot(5)])
        self.assertEqual(len(self.shotseries), 100)
        ss.merge([self.createshot(500)])
        self.assertEqual(len(self.shotseries), 101)
        s = pe.Shot(id=50, a=50)

        def test():
            ss.merge([s])

        self.assertRaises(ValueError, test)
Beispiel #3
0
 def test_unknwoncontent(self):
     # empty Shot
     shot = pe.Shot({})
     shot['test'] = 'actual data'
     self.assertEqual(len(shot), 1)
     # data that should be ignored
     for unknown in pe.Shot.unknowncontent:
         shot['test'] = unknown
     # double checking
     shot['test'] = []
     shot['test'] = ()
     shot['test'] = 'unknown'
     # numpy array cases require special care
     for unknown in pe.Shot.unknowncontent:
         shot['test'] = np.array(unknown)
         shot['test'] = np.array([unknown])
Beispiel #4
0
 def test_double_init(self):
     self.sa.update(x=pe.LazyAccessDummy(42, exceptonaccess=True))
     newshot = pe.Shot(self.sa)
     self.assertTrue(isinstance(newshot, pe.Shot))
     self.assertTrue(isinstance(self.sa._mapping['x'], pe.LazyAccess))
     self.assertTrue(newshot is self.sa)
Beispiel #5
0
 def test_init(self):
     s = pe.Shot(self.a)
     self.assertEqual(len(s), 4)
     # unknwon content should be ignored
     s['d'] = 'None'
     self.assertEqual(len(s), 4)
Beispiel #6
0
 def createshot(self, i):
     return pe.Shot(id=i, a=i + 1, b=i - 1)
Beispiel #7
0
 def setUp(self):
     self.a = dict(id=0, a=1, b=2, c=3)
     self.sa = pe.Shot(self.a)