code: def add_oxidation_state_by_element(self, oxidation_states):
          
          try:
              for site in self.sites:
                  new_sp = {}
                  for el, occu in site.species.items():
                      sym = el.symbol
                      new_sp[Specie(sym, oxidation_states[sym])] = occu
                  site.species = new_sp
          except KeyError:
              raise ValueError("Oxidation state of all elements must be "
                               "specified in the dictionary.")
docs: Add oxidation states.
  
          Args:
              oxidation_states (dict): Dict of oxidation states.
                  E.g., {"Li":1, "Fe":2, "P":5, "O":-2}