³ò
™§ZGc        	   @   s~   d  Z  d d k Z d d k Z d d k i Z d d k i i	 Z
 d d k i Z d d k Td d d „ Z d d d „  ƒ  YZ d S(   sB   
This module contains the instantiations of color mapping classes
iÿÿÿÿN(   t   *c         C   sm   |  d j o t i d }  n | d j o t i d } n |  t i ƒ  j p t ‚ t i |  t |  | ƒ S(   sJ   
    Get a colormap instance, defaulting to rc values if name is None
    s
   image.cmaps	   image.lutN(   t   Nonet   mplt   rcParamst   datadt   keyst   AssertionErrort   colorst   LinearSegmentedColormap(   t   namet   lut(    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   get_cmap   s    t   ScalarMappablec           B   s°   e  Z d  Z d d d „ Z d „  Z d e d „ Z d „  Z d „  Z	 d „  Z
 d d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sn   
    This is a mixin class to support scalar -> RGBA mapping.  Handles
    normalization and colormapping
    c         C   sz   | d j o t ƒ  } n | d j o t i ƒ  } n d |  _ | |  _ | |  _ g  |  _ d |  _ h  t	 d <|  _
 d S(   st   
        norm is a colors.normalize instance to map luminance to 0-1
        cmap is a cm colormap instance
        t   arrayN(   R   R   R   t	   Normalizet   _At   normt   cmapt	   observerst   colorbart   Falset   update_dict(   t   selfR   R   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   __init__   s    					c         C   s   | | f |  _  d S(   s8   set the colorbar image and axes associated with mappableN(   R   (   R   t   imt   ax(    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   set_colorbar.   s    g      ð?c      
   C   s  y=| i  d j o)| i d d j o¯ | i t i j o t i | d t i ƒ } n | i d  \ } } t i d | | d f d | i ƒ } | | d d … d d … d d … f <| | d d … d d … d f <n+ | i d d j o
 | } n t d ƒ ‚ | o- | i t i j o | d i t i ƒ } n | Sn Wn t	 j
 o n Xt
 i | ƒ } |  i | ƒ } |  i | d	 | d
 | ƒ} | S(   sê   Return a normalized rgba array corresponding to x.
        If x is already an rgb array, insert alpha; if it is
        already rgba, return it unchanged.
        If bytes is True, return rgba as 4 uint8s instead of 4 floats.
        i   i   iÿ   t   shapei   t   dtypeNs   third dimension must be 3 or 4t   alphat   bytes(   t   ndimR   R   t   npyt   uint8R   t   emptyt
   ValueErrort   astypet   AttributeErrort   mat   asarrayR   R   (   R   t   xR   R   t   mt   nt   xx(    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   to_rgba2   s*    $%#
c         C   s   | |  _  t |  i d <d S(   s&   Set the image array from numpy array AR   N(   R   t   TrueR   (   R   t   A(    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt	   set_arrayO   s    	c         C   s   |  i  S(   s   Return the array(   R   (   R   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt	   get_arrayT   s    c         C   s   |  i  i |  i  i f S(   s9   return the min, max of the color limits for image scaling(   R   t   vmint   vmax(   R   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   get_climX   s    c         C   s•   | d j	 o@ | d j o3 t i | ƒ o# t | ƒ d j o | \ } } n | d j	 o | |  i _ n | d j	 o | |  i _ n |  i ƒ  d S(   sÒ   
        set the norm limits for image scaling; if vmin is a length2
        sequence, interpret it as (vmin, vmax) which is used to
        support setp

        ACCEPTS: a length 2 sequence of floats
        i   N(   R   t   cbookt   iterablet   lenR   R1   R2   t   changed(   R   R1   R2   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   set_clim\   s    #c         C   s1   | d j o t ƒ  } n | |  _ |  i ƒ  d S(   sR   
        set the colormap for luminance data

        ACCEPTS: a colormap
        N(   R   R   R   R7   (   R   R   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   set_cmapl   s    	c         C   s4   | d j o t i ƒ  } n | |  _ |  i ƒ  d S(   s   set the normalization instanceN(   R   R   R   R   R7   (   R   R   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   set_normv   s    	c         C   sA   |  i  d j o t d ƒ ‚ n |  i i |  i  ƒ |  i ƒ  d S(   sb   
        Autoscale the scalar limits on the norm instance using the
        current array
        s%   You must first set_array for mappableN(   R   R   t	   TypeErrorR   t	   autoscaleR7   (   R   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyR<   |   s    c         C   sA   |  i  d j o t d ƒ ‚ n |  i i |  i  ƒ |  i ƒ  d S(   s†   
        Autoscale the scalar limits on the norm instance using the
        current array, changing only limits that are None
        s%   You must first set_array for mappableN(   R   R   R;   R   t   autoscale_NoneR7   (   R   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyR=   †   s    c         C   s   t  |  i | <d S(   sz   
        Add an entry to a dictionary of boolean flags
        that are set to True when the mappable is changed.
        N(   R   R   (   R   t   checker(    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   add_checker‘   s    c         C   s'   |  i  | o t |  i  | <t Sn t S(   sf   
        If mappable has changed since the last check,
        return True; else return False
        (   R   R   R-   (   R   R>   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   check_update˜   s    c         C   s>   |  i  i | ƒ y |  i | i ƒ Wn t j
 o n Xd S(   sâ   
        whenever the norm, clim or cmap is set, call the notify
        instance of the mappable observer with self.

        This is designed to allow one image to follow changes in the
        cmap of another image
        N(   R   t   appendt   add_callbackt   notifyR%   (   R   t   mappable(    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyt   add_observer¢   s
    c         C   sQ   |  i  | i ƒ |  i | i ƒ y |  i | i ƒ  ƒ Wn t j
 o n Xd S(   s‰   
        If this is called then we are pegged to another mappable.
        Update our cmap, norm, alpha from the other mappable.
        N(   R9   R   R:   R   t	   set_alphat	   get_alphaR%   (   R   RD   (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyRC   °   s    c         C   sF   x |  i  D] } | i |  ƒ q
 Wx |  i D] } t |  i | <q+ Wd S(   sb   
        Call this whenever the mappable is changed so observers can
        update state
        N(   R   RC   R   R-   (   R   t   observert   key(    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyR7   ¼   s    
 
 N(   t   __name__t
   __module__t   __doc__R   R   R   R   R,   R/   R0   R3   R8   R9   R:   R<   R=   R?   R@   RE   RC   R7   (    (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pyR      s"   					
		
			
		(    (   RL   t   numpyR    t
   matplotlibR   t   matplotlib.colorsR   t   matplotlib.numerix.npymat   numerixt   npymaR&   t   matplotlib.cbookR4   t   matplotlib._cmR   R   R   (    (    (    s6   /Users/cmoad/workspace/matplotlib/lib/matplotlib/cm.pys   <module>   s   

