Example #1
0
File: test.py Project: luasdtu/MMPE
 def test_nan_float(self):
     fn = self.f + 'nan.hdf5'
     d = np.arange(12, dtype=np.float32).reshape(6, 2)
     d[2, 0] = np.nan
     gtsdf.save(fn, d)
     _, data, _ = gtsdf.load(fn)
     np.testing.assert_array_almost_equal(data, d, 4)
Example #2
0
File: test.py Project: luasdtu/MMPE
 def test_float_time(self):
     fn = self.f + 'time.hdf5'
     gtsdf.save(fn,
                np.arange(12).reshape(6, 2),
                time=np.arange(4, 5.5, .25))
     time, _, _ = gtsdf.load(fn)
     np.testing.assert_array_equal(time, np.arange(4, 5.5, .25))
Example #3
0
File: test.py Project: luasdtu/MMPE
 def test_time_offset(self):
     fn = self.f + 'time.hdf5'
     gtsdf.save(fn,
                np.arange(12).reshape(6, 2),
                time=range(6),
                time_start=4)
     time, _, _ = gtsdf.load(fn)
     np.testing.assert_array_equal(time, range(4, 10))
Example #4
0
File: test.py Project: luasdtu/MMPE
 def test_data_float(self):
     fn = self.f + 'time.hdf5'
     d = np.arange(12).reshape(6, 2)
     gtsdf.save(fn, d, dtype=np.float32)
     f = h5py.File(fn)
     self.assertEqual(f['block0000']['data'].dtype, np.float32)
     f.close()
     _, data, _ = gtsdf.load(fn)
     np.testing.assert_array_equal(data, np.arange(12).reshape(6, 2))
Example #5
0
File: test.py Project: luasdtu/MMPE
 def test_data(self):
     fn = self.f + 'data.hdf5'
     d = np.arange(12).reshape(6, 2)
     gtsdf.save(fn, d)
     f = h5py.File(fn)
     self.assertEqual(f['block0000']['data'].dtype, np.uint16)
     f.close()
     _, data, _ = gtsdf.load(fn)
     np.testing.assert_array_almost_equal(data,
                                          np.arange(12).reshape(6, 2), 4)
Example #6
0
File: test.py Project: luasdtu/MMPE
 def test_append(self):
     fn = self.f + 'append.hdf5'
     d = np.arange(12, dtype=np.float32).reshape(6, 2)
     d[2, 0] = np.nan
     gtsdf.save(fn, d)
     _, data, _ = gtsdf.load(fn)
     np.testing.assert_array_almost_equal(data, d, 4)
     gtsdf.append_block(fn, d)
     _, data, _ = gtsdf.load(fn)
     self.assertEqual(data.shape, (12, 2))
     np.testing.assert_array_almost_equal(data, np.append(d, d, 0), 4)
Example #7
0
File: test.py Project: luasdtu/MMPE
 def test_info(self):
     fn = self.f + "info.hdf5"
     gtsdf.save(fn,
                np.arange(12).reshape(6, 2),
                name='datasetname',
                description='datasetdescription',
                attribute_names=['att1', 'att2'],
                attribute_units=['s', 'm/s'],
                attribute_descriptions=['d1', 'd2'])
     _, _, info = gtsdf.load(fn)
     self.assertEqual(info['name'], "datasetname")
     self.assertEqual(info['type'], "General time series data format")
     self.assertEqual(info['description'], "datasetdescription")
     self.assertEqual(list(info['attribute_names']), ['att1', 'att2'])
     self.assertEqual(list(info['attribute_units']), ['s', 'm/s'])
     self.assertEqual(list(info['attribute_descriptions']), ['d1', 'd2'])
Example #8
0
File: test.py Project: luasdtu/MMPE
 def test_all(self):
     fn = self.f + "all.hdf5"
     gtsdf.save(fn,
                np.arange(12).reshape(6, 2),
                name='datasetname',
                time=range(6),
                time_step=1 / 4,
                time_start=4,
                description='datasetdescription',
                attribute_names=['att1', 'att2'],
                attribute_units=['s', 'm/s'],
                attribute_descriptions=['d1', 'd2'])
     time, data, info = gtsdf.load(fn)
     self.assertEqual(info['name'], "datasetname")
     self.assertEqual(info['type'], "General time series data format")
     self.assertEqual(info['description'], "datasetdescription")
     self.assertEqual(list(info['attribute_names']), ['att1', 'att2'])
     self.assertEqual(list(info['attribute_units']), ['s', 'm/s'])
     self.assertEqual(list(info['attribute_descriptions']), ['d1', 'd2'])
     np.testing.assert_array_equal(time, np.arange(4, 5.5, .25))
     np.testing.assert_array_almost_equal(data,
                                          np.arange(12).reshape(6, 2), 4)
Example #9
0
File: test.py Project: luasdtu/MMPE
 def test_load_fileobject(self):
     fn = self.f + "fileobject.hdf5"
     gtsdf.save(fn, np.arange(12).reshape(4, 3))
     _, _, info = gtsdf.load(fn)
     self.assertEqual(info['name'], 'fileobject')
Example #10
0
File: test.py Project: luasdtu/MMPE
 def test_save_no_hdf5_ext(self):
     fn = self.f + "no_hdf5_ext"
     gtsdf.save(fn, np.arange(12).reshape(4, 3))
     _, _, info = gtsdf.load(fn + ".hdf5")
     self.assertEqual(info['name'], 'no_hdf5_ext')
Example #11
0
File: test.py Project: luasdtu/MMPE
 def test_no_time(self):
     fn = self.f + 'time.hdf5'
     gtsdf.save(fn, np.arange(12).reshape(6, 2))
     time, _, _ = gtsdf.load(fn)
     np.testing.assert_array_equal(time, np.arange(6))