code: def get_band_gap(self):
          
          if self.is_metal():
              return {"energy": 0.0, "direct": False, "transition": None}
          cbm = self.get_cbm()
          vbm = self.get_vbm()
          result = dict(direct=False, energy=0.0, transition=None)
  
          result["energy"] = cbm["energy"] - vbm["energy"]
  
          if (cbm["kpoint"].label is not None and cbm["kpoint"].label == vbm[
              "kpoint"].label) \
                  or np.linalg.norm(cbm["kpoint"].cart_coords
                                    - vbm["kpoint"].cart_coords) < 0.01:
              result["direct"] = True
  
          result["transition"] = "-".join(
              [str(c.label) if c.label is not None else
               str("(") + ",".join(["{0:.3f}".format(c.frac_coords[i])
                                    for i in range(3)])
               + str(")") for c in [vbm["kpoint"], cbm["kpoint"]]])
  
          return result
docs: Returns band gap data.
  
          Returns:
              A dict {"energy","direct","transition"}:
              "energy": band gap energy
              "direct": A boolean telling if the gap is direct or not
              "transition": kpoint labels of the transition (e.g., "\\Gamma-X")