def test_to_hdf5(self): """Test to_hdf5.""" random = np.random.rand(2, 2) ints = OneBodyElectronicIntegrals(ElectronicBasis.MO, (random, random)) with tempfile.TemporaryFile() as tmp_file: with h5py.File(tmp_file, "w") as file: ints.to_hdf5(file)
def test_from_hdf5(self): """Test from_hdf5.""" random = np.random.rand(2, 2) ints = OneBodyElectronicIntegrals(ElectronicBasis.MO, (random, random)) with tempfile.TemporaryFile() as tmp_file: with h5py.File(tmp_file, "w") as file: ints.to_hdf5(file) with h5py.File(tmp_file, "r") as file: new_ints = OneBodyElectronicIntegrals.from_hdf5(file["OneBodyElectronicIntegrals"]) self.assertEqual(ints, new_ints)