def test_save_to_binary_file(self): tmpfile = gf.generate_temp_file(extension='h5') CP._save_to_bin_file(filename=tmpfile, datasetname='d1', mtx=np.array([0.1, 0.2])) self.assertTrue(os.path.isfile(tmpfile), msg='File exists') os.remove(tmpfile)
def test_readingbinaryfile_array(self): tmpfile = gf.generate_temp_file(extension='h5') CP._save_to_bin_file(filename=tmpfile, datasetname='d1', mtx=np.array([[0.1, 0.2]])) self.assertTrue(os.path.isfile(tmpfile), msg='File exists') out = CP.read_in_bin_file(filename=tmpfile) self.assertTrue(np.array_equal(out, np.array([[0.1, 0.2]])), msg=str('Expected array match: {}'.format(out))) os.remove(tmpfile)