def register_cmap_safe(name, data):
 try:
  return cm.get_cmap(name)
 except ValueError:
  cmap = LinearSegmentedColormap.from_list(name, data)
  cm.register_cmap(name, cmap)
  return cmap

def register_cmap_safe ( name , data ) : try : return cm . get_cmap ( name ) except ValueError : cmap = LinearSegmentedColormap . from_list ( name , data ) cm . register_cmap ( name , cmap ) return cmap
register a colormap if not already registered .