from __future__ import absolute_import, division, print_function

from ..utils import identity, alias
from .scale import scale_discrete, scale_continuous


class scale_color_identity(scale_discrete):
    aesthetics = ['color']
    palette = staticmethod(identity)


class scale_fill_identity(scale_color_identity):
    aesthetics = ['fill']


class scale_shape_identity(scale_discrete):
    aesthetics = ['shape']
    palette = staticmethod(identity)


class scale_linetype_identity(scale_discrete):
    aesthetics = ['linetype']
    palette = staticmethod(identity)


class scale_alpha_identity(scale_continuous):
    aesthetics = ['alpha']
    palette = staticmethod(identity)


class scale_size_identity(scale_continuous):
    aesthetics = ['size']
    palette = staticmethod(identity)


# American to British spelling
alias('scale_colour_identity', scale_color_identity)

from __future__ import absolute_import, division, print_function

from ..utils import identity, alias
from .scale import scale_discrete, scale_continuous


class MapTrainMixin(object):
    """
    Override map and train methods
    """
    def map(self, x):
        return x

    def train(self, x):
        # do nothing if no guide,
        # otherwise train so we know what breaks to use
        if self.guide is None:
            return

        return super(MapTrainMixin, self).train(x)


class scale_color_identity(MapTrainMixin, scale_discrete):
    aesthetics = ['color']
    palette = staticmethod(identity)
    guide = None


class scale_fill_identity(scale_color_identity):
    aesthetics = ['fill']


class scale_shape_identity(MapTrainMixin, scale_discrete):
    aesthetics = ['shape']
    palette = staticmethod(identity)
    guide = None


class scale_linetype_identity(MapTrainMixin, scale_discrete):
    aesthetics = ['linetype']
    palette = staticmethod(identity)
    guide = None


class scale_alpha_identity(MapTrainMixin, scale_continuous):
    aesthetics = ['alpha']
    palette = staticmethod(identity)
    guide = None


class scale_size_identity(MapTrainMixin, scale_continuous):
    aesthetics = ['size']
    palette = staticmethod(identity)
    guide = None


# American to British spelling
alias('scale_colour_identity', scale_color_identity)

Fix identity scales, override map & train methods
Fix identity scales, override map & train methods

  from __future__ import absolute_import, division, print_function
  
  from ..utils import identity, alias
  from .scale import scale_discrete, scale_continuous
  
  
+ class MapTrainMixin(object):
+     """
+     Override map and train methods
+     """
+     def map(self, x):
+         return x
+ 
+     def train(self, x):
+         # do nothing if no guide,
+         # otherwise train so we know what breaks to use
+         if self.guide is None:
+             return
+ 
+         return super(MapTrainMixin, self).train(x)
+ 
+ 
- class scale_color_identity(scale_discrete):
+ class scale_color_identity(MapTrainMixin, scale_discrete):
      aesthetics = ['color']
      palette = staticmethod(identity)
+     guide = None
  
  
  class scale_fill_identity(scale_color_identity):
      aesthetics = ['fill']
  
  
- class scale_shape_identity(scale_discrete):
+ class scale_shape_identity(MapTrainMixin, scale_discrete):
      aesthetics = ['shape']
      palette = staticmethod(identity)
+     guide = None
  
  
- class scale_linetype_identity(scale_discrete):
+ class scale_linetype_identity(MapTrainMixin, scale_discrete):
      aesthetics = ['linetype']
      palette = staticmethod(identity)
+     guide = None
  
  
- class scale_alpha_identity(scale_continuous):
+ class scale_alpha_identity(MapTrainMixin, scale_continuous):
      aesthetics = ['alpha']
      palette = staticmethod(identity)
+     guide = None
  
  
- class scale_size_identity(scale_continuous):
+ class scale_size_identity(MapTrainMixin, scale_continuous):
      aesthetics = ['size']
      palette = staticmethod(identity)
+     guide = None
  
  
  # American to British spelling
  alias('scale_colour_identity', scale_color_identity)
  
Fix identity scales, override map & train methods
## Code Before:
from __future__ import absolute_import, division, print_function

from ..utils import identity, alias
from .scale import scale_discrete, scale_continuous


class scale_color_identity(scale_discrete):
    aesthetics = ['color']
    palette = staticmethod(identity)


class scale_fill_identity(scale_color_identity):
    aesthetics = ['fill']


class scale_shape_identity(scale_discrete):
    aesthetics = ['shape']
    palette = staticmethod(identity)


class scale_linetype_identity(scale_discrete):
    aesthetics = ['linetype']
    palette = staticmethod(identity)


class scale_alpha_identity(scale_continuous):
    aesthetics = ['alpha']
    palette = staticmethod(identity)


class scale_size_identity(scale_continuous):
    aesthetics = ['size']
    palette = staticmethod(identity)


# American to British spelling
alias('scale_colour_identity', scale_color_identity)

## Instruction:
Fix identity scales, override map & train methods
## Code After:
from __future__ import absolute_import, division, print_function

from ..utils import identity, alias
from .scale import scale_discrete, scale_continuous


class MapTrainMixin(object):
    """
    Override map and train methods
    """
    def map(self, x):
        return x

    def train(self, x):
        # do nothing if no guide,
        # otherwise train so we know what breaks to use
        if self.guide is None:
            return

        return super(MapTrainMixin, self).train(x)


class scale_color_identity(MapTrainMixin, scale_discrete):
    aesthetics = ['color']
    palette = staticmethod(identity)
    guide = None


class scale_fill_identity(scale_color_identity):
    aesthetics = ['fill']


class scale_shape_identity(MapTrainMixin, scale_discrete):
    aesthetics = ['shape']
    palette = staticmethod(identity)
    guide = None


class scale_linetype_identity(MapTrainMixin, scale_discrete):
    aesthetics = ['linetype']
    palette = staticmethod(identity)
    guide = None


class scale_alpha_identity(MapTrainMixin, scale_continuous):
    aesthetics = ['alpha']
    palette = staticmethod(identity)
    guide = None


class scale_size_identity(MapTrainMixin, scale_continuous):
    aesthetics = ['size']
    palette = staticmethod(identity)
    guide = None


# American to British spelling
alias('scale_colour_identity', scale_color_identity)
