Beispiel #1
0
 def test_get_hdf5_by_dir(self):
     ''' Test get_hdf5_by_dir(). '''
     dset = zsimparse.get_hdf5_by_dir(self.simdir)
     self.assertIsNotNone(dset)
     self.assertGreater(zsimparse.hdf5_get(dset, 'phase'), 0)
     dset = zsimparse.get_hdf5_by_dir(self.simdir, suffix='')
     self.assertGreater(dset.shape[0], 1)
Beispiel #2
0
 def test_get_hdf5_by_dir(self):
     ''' Test get_hdf5_by_dir(). '''
     stat = zsimparse.get_hdf5_by_dir(self.simdir)
     self.assertIsNotNone(stat)
     self.assertGreater(stat.num_samples(), 1)
     stat_first = zsimparse.hdf5_get(stat, 0)
     stat_last = zsimparse.hdf5_get(stat, -1)
     self.assertEqual(stat_first['phase'], 0)
     self.assertGreater(stat_last['phase'], 0)
     self.assertEqual(
         zsimparse.get_hdf5_by_dir(self.simdir, final_only=True).raw,
         stat_last)
Beispiel #3
0
 def test_get_hdf5_by_dir_bad_dir(self):
     ''' Test get_hdf5_by_dir() when dir is invalid. '''
     bad_dir = os.path.join(self.simdir, 'sim')
     try:
         _ = zsimparse.get_hdf5_by_dir(bad_dir)
     except ValueError as e:
         self.assertIn('hdf5', str(e))
Beispiel #4
0
 def setUp(self):
     # Example sim directory.
     self.simdir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                'simdir')
     # Get config.
     self.cfg = zsimparse.get_config_by_dir(self.simdir)
     # Get hdf5 dataset.
     self.dset = zsimparse.get_hdf5_by_dir(self.simdir, final_only=True)
Beispiel #5
0
    def test_hdf5_get(self):
        ''' Test hdf5_get(). '''
        stat = zsimparse.get_hdf5_by_dir(self.simdir)

        last_l2_putx = 0
        last_c0_instrs = 0
        for idx in range(stat.num_samples()):
            c0_instrs = zsimparse.hdf5_get(stat,
                                           (idx, 'simpleCore', 0, 'instrs'))
            l2_putx = zsimparse.hdf5_get(stat, (idx, 'l2', 0, 'PUTX'))
            self.assertGreaterEqual(c0_instrs, last_c0_instrs)
            self.assertGreaterEqual(l2_putx, last_l2_putx)
Beispiel #6
0
    def test_hdf5_get_final_only(self):
        ''' Test hdf5_get() for final only. '''
        stat = zsimparse.get_hdf5_by_dir(self.simdir, final_only=True)

        l2_putx = zsimparse.hdf5_get(stat, ('l2', 0, 'PUTX'))
        self.assertEqual(l2_putx, 1545)
        self.assertEqual(stat['l2'][0]['PUTX'], l2_putx)

        sched_rqszhist = stat.lookup('sched.rqSzHist')
        self.assertEqual(sched_rqszhist.num_samples(), 17)
        self.assertEqual(sched_rqszhist.num_dims(), 1)
        sched_rqszhist = sched_rqszhist.raw
        self.assertEqual(sched_rqszhist[0], 121)
        self.assertTrue((sched_rqszhist[1:] == 0).all())
        self.assertTrue((stat['sched']['rqSzHist'] == sched_rqszhist).all())
Beispiel #7
0
    def test_hdf5_get_invalid_names(self):
        ''' Test hdf5_get() with invalid names. '''
        stat = zsimparse.get_hdf5_by_dir(self.simdir)

        self.assertIsNone(zsimparse.hdf5_get(stat, ('g1', 't1')))
        self.assertIsNone(zsimparse.hdf5_get(stat, 'root g2 t1'))
        self.assertIsNone(zsimparse.hdf5_get(stat, 'g3'))
        self.assertIsNone(zsimparse.hdf5_get(stat, (-1, 'phase', 'g3')))

        with self.assertRaises(ValueError):
            _ = stat['g1']['t1']
        with self.assertRaises(ValueError):
            _ = stat['root']['g2']['t1']
        with self.assertRaises(ValueError):
            _ = stat['g3']
        with self.assertRaises(IndexError):
            _ = stat[-1]['phase']['g3']
Beispiel #8
0
 def test_get_hdf5_by_dir_bad_dir(self):
     ''' Test get_hdf5_by_dir() when dir is invalid. '''
     bad_dir = os.path.join(self.simdir, 'sim')
     with self.assertRaisesRegex(ValueError, '.*h5.*'):
         _ = zsimparse.get_hdf5_by_dir(bad_dir)
Beispiel #9
0
 def test_hdf5_lookup(self):
     ''' Test lookup(). '''
     val = zsimparse.get_hdf5_by_dir(self.simdir)
     for key in (-1, 'l2', 0, 'PUTX'):
         val = val.lookup(key)
     self.assertEqual(val.raw, 1545)
Beispiel #10
0
 def test_raw_stat_input(self):
     ''' Test with a raw stat input. '''
     data = zsimparse.get_hdf5_by_dir(self.simdir)
     self.assertEqual(zsimparse.get_cache_hit(self.dset, 'l2'),
                      zsimparse.get_cache_hit(data[-1], 'l2'))
Beispiel #11
0
 def test_get_hdf5_by_dir_bad_suffix(self):
     ''' Test get_hdf5_by_dir() when suffix is invalid. '''
     try:
         _ = zsimparse.get_hdf5_by_dir(self.simdir, suffix='abc')
     except ValueError as e:
         self.assertIn('suffix', str(e))