code: def _get_radius(site):
          
          if hasattr(site.specie, 'oxi_state'):
              el = site.specie.element
              oxi = site.specie.oxi_state
  
              if oxi == 0:
                  return CrystalNN._get_default_radius(site)
  
              elif oxi in el.ionic_radii:
                  return el.ionic_radii[oxi]
  
              # e.g., oxi = 2.667, average together 2+ and 3+ radii
              elif int(math.floor(oxi)) in el.ionic_radii and \
                      int(math.ceil(oxi)) in el.ionic_radii:
                  oxi_low = el.ionic_radii[int(math.floor(oxi))]
                  oxi_high = el.ionic_radii[int(math.ceil(oxi))]
                  x = oxi - int(math.floor(oxi))
                  return (1 - x) * oxi_low + x * oxi_high
  
              elif oxi > 0 and el.average_cationic_radius > 0:
                  return el.average_cationic_radius
  
              elif oxi < 0 and el.average_anionic_radius > 0:
                  return el.average_anionic_radius
  
          else:
              warnings.warn("CrystalNN: distance cutoffs set but no oxidation "
                            "states specified on sites! For better results, set "
                            "the site oxidation states in the structure.")
          return 0
docs: An internal method to get the expected radius for a site with
          oxidation state.
          Args:
              site: (Site)
  
          Returns:
              Oxidation-state dependent radius: ionic, covalent, or atomic.
              Returns 0 if no oxidation state or appropriate radius is found.