code: def make_scale(ae, series, *args, **kwargs):
      """
      Return a proper scale object for the series
  
      The scale is for the aesthetic ae, and args & kwargs
      are passed on to the scale creating class
      """
      if pdtypes.is_float_dtype(series) and np.isinf(series).all():
          raise PlotnineError("Cannot create scale for infinite data")
  
      stype = scale_type(series)
  
      # filter parameters by scale type
      if stype in ("discrete", "ordinal"):
          with suppress(KeyError):
              del kwargs["trans"]
  
      scale_name = f"scale_{ae}_{stype}"
      scale_klass = Registry[scale_name]
      return scale_klass(*args, **kwargs)
  
imports: from __future__ import annotations
  import itertools
  import typing
  from contextlib import suppress
  from typing import List
  from warnings import warn
  import numpy
  import pandas.api.types
  from .._utils import array_kind
  from .._utils.registry import Registry
  from ..exceptions import PlotnineError, PlotnineWarning
  from ..mapping.aes import aes_to_scale
  from .scale import scale
label_desc: Use image node_id 2 for calling a global function with example usage: make_scale(ae, series) and returns: scale_klass