Esempio n. 1
0
 def test_undo_last_transformation_and_redo(self):
     trans = []
     trans.append(SubstitutionTransformation({"Li":"Na"}))
     trans.append(SubstitutionTransformation({"Fe":"Mn"}))
     ts = TransformedStructure(self.structure, trans)
     self.assertEqual("NaMnPO4", ts.final_structure.composition.reduced_formula)
     ts.undo_last_transformation()
     self.assertEqual("NaFePO4", ts.final_structure.composition.reduced_formula)
     ts.undo_last_transformation()
     self.assertEqual("LiFePO4", ts.final_structure.composition.reduced_formula)
     self.assertRaises(IndexError, ts.undo_last_transformation)
     ts.redo_next_transformation()
     self.assertEqual("NaFePO4", ts.final_structure.composition.reduced_formula)
     ts.redo_next_transformation()
     self.assertEqual("NaMnPO4", ts.final_structure.composition.reduced_formula)
     self.assertRaises(IndexError, ts.redo_next_transformation)