def test_electronic_structure_modification_in_place(): """Test that ElectronicStructure instances can be modified in-place""" struct = ElectronicStructure({"1s": 2, "2s": 2, "2p": 4}) expected = ElectronicStructure({"1s": 2, "2s": 2, "2p": 3, "4s": 1}) struct["2p"] -= 1 struct["4s"] += 1 assert struct == expected
def test_modification_in_place(self): """ Test that ElectronicStructure instances can be modified in-place """ struct = ElectronicStructure({"1s": 2, "2s": 2, "2p": 4}) expected = ElectronicStructure({"1s": 2, "2s": 2, "2p": 3, "4s": 1}) struct["2p"] -= 1 struct["4s"] += 1 self.assertEqual(struct, expected)
def test_valence_shell(self): """ Test that the outermost shell is as expected """ struct = ElectronicStructure({"1s": 2}) self.assertEqual(struct.outer_shell, Orbital("1s")) # Intentionally omitting 2s struct = ElectronicStructure({"1s": 2, "2p": 4}) self.assertEqual(struct.outer_shell, Orbital("2p"))
def test_electronic_structure_valence_shell(): """Test that the outermost shell is as expected""" struct = ElectronicStructure({"1s": 2}) assert struct.outer_shell == Orbital("1s") # Intentionally omitting 2s struct = ElectronicStructure({"1s": 2, "2p": 4}) assert struct.outer_shell == Orbital("2p")
def test_orbital_keys(self): """ Test that orbital occupancies can be accessed either with strings or Orbital """ struct = ElectronicStructure.ground_state("He") self.assertEqual(struct["1s"], struct[Orbital.one_s])
def test_missing_orbital(self): """ Test that 'missing' orbitals will return 0 electrons """ struct = ElectronicStructure.ground_state("He") self.assertEqual(struct["2p"], 0)
def test_pickable(self): """ Test that ElectronicStructure instances are pickable. """ structure = ElectronicStructure.ground_state("W") self.assertEqual(structure, pickle.loads(pickle.dumps(structure)))
def test_maximum_electrons(self): """ Test that an error is raised for impossible electronic structures. """ with self.assertRaises(ValueError): ElectronicStructure({"1s": 3})
def test_electronic_structure_orbital_keys(): """Test that orbital occupancies can be accessed either with strings or Orbital""" struct = ElectronicStructure.ground_state("He") assert struct["1s"] == struct[Orbital.one_s]
def test_electronic_structure_missing_orbital(): """Test that 'missing' orbitals will return 0 electrons""" struct = ElectronicStructure.ground_state("He") assert struct["2p"] == 0
def test_electronic_structure_pickable(): """Test that ElectronicStructure instances are pickable.""" structure = ElectronicStructure.ground_state("W") assert structure == pickle.loads(pickle.dumps(structure))
def test_electronic_structure_maximum_electrons(): """Test that an error is raised for impossible electronic structures.""" with pytest.raises(ValueError): ElectronicStructure({"1s": 3})