def setUp(self):
     self.data = pd.DataFrame(np.random.random((2, 2)))
     data_utils.save_hdf5_data('test.h5',
                               self.data,
                               pandas_format=False,
                               mode='w',
                               key='test_data')
     data_utils.save_hdf5_data('test_pandas.h5',
                               self.data,
                               pandas_format=True,
                               mode='w',
                               key='test_data')
 def test_pandas_append(self):
     data = pd.DataFrame(np.random.random((2, 2)))
     data_utils.save_hdf5_data('test_pandas.h5',
                               data,
                               pandas_format=True,
                               key='test_data',
                               append=True)
     newData = np.concatenate((self.data.values, data.values))
     np.testing.assert_array_equal(
         newData,
         data_utils.load_hdf5_data('test_pandas.h5',
                                   pandas_format=True,
                                   key='test_data').values)
 def test_overwriting(self):
     data = pd.DataFrame(np.ones((2, 2)))
     data_utils.save_hdf5_data('test.h5',
                               data,
                               pandas_format=False,
                               key='test_data')
     self.assertEqual(
         np.any(
             np.not_equal(
                 self.data.values,
                 data_utils.load_hdf5_data('test.h5',
                                           pandas_format=False,
                                           key='test_data'))), True)
 def test_saving_assertions(self):
     data = np.ones((2, 2))
     with self.assertRaises(exceptions.FileSaveError):
         data_utils.save_hdf5_data('test.h5', data, key='test_data')