def test_undo_and_redo_last_change(self): trans = [ SubstitutionTransformation({"Li": "Na"}), SubstitutionTransformation({"Fe": "Mn"}) ] ts = TransformedStructure(self.structure, trans) self.assertEqual("NaMnPO4", ts.final_structure.composition.reduced_formula) ts.undo_last_change() self.assertEqual("NaFePO4", ts.final_structure.composition.reduced_formula) ts.undo_last_change() self.assertEqual("LiFePO4", ts.final_structure.composition.reduced_formula) self.assertRaises(IndexError, ts.undo_last_change) ts.redo_next_change() self.assertEqual("NaFePO4", ts.final_structure.composition.reduced_formula) ts.redo_next_change() self.assertEqual("NaMnPO4", ts.final_structure.composition.reduced_formula) self.assertRaises(IndexError, ts.redo_next_change) #Make sure that this works with filters. f3 = ContainsSpecieFilter(['O2-'], strict_compare=True, AND=False) ts.append_filter(f3) ts.undo_last_change() ts.redo_next_change()
def test_undo_and_redo_last_change(self): trans = [SubstitutionTransformation({"Li": "Na"}), SubstitutionTransformation({"Fe": "Mn"})] ts = TransformedStructure(self.structure, trans) self.assertEqual("NaMnPO4", ts.final_structure.composition.reduced_formula) ts.undo_last_change() self.assertEqual("NaFePO4", ts.final_structure.composition.reduced_formula) ts.undo_last_change() self.assertEqual("LiFePO4", ts.final_structure.composition.reduced_formula) self.assertRaises(IndexError, ts.undo_last_change) ts.redo_next_change() self.assertEqual("NaFePO4", ts.final_structure.composition.reduced_formula) ts.redo_next_change() self.assertEqual("NaMnPO4", ts.final_structure.composition.reduced_formula) self.assertRaises(IndexError, ts.redo_next_change) #Make sure that this works with filters. f3 = ContainsSpecieFilter(['O2-'], strict_compare=True, AND=False) ts.append_filter(f3) ts.undo_last_change() ts.redo_next_change()