ó
¦–Õ\c           @` sê  d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l m Z m	 Z	 m
 Z
 d d l m Z m Z m Z m Z d d l Z d d l Z d d l m Z m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z m Z m Z d d l m Z d d l  m! Z! d d l" m# Z# d „  Z$ d „  Z% d „  Z& d „  Z' d „  Z( d d d „ Z* d „  Z+ d „  Z, d „  Z- d „  Z. d „  Z/ d „  Z0 d „  Z1 d d d „ Z2 d „  Z3 d e4 f d  „  ƒ  YZ5 d! „  Z6 d" „  Z7 d# „  Z8 d S($   sÚ   
The rechunk module defines:
    intersect_chunks: a function for
        converting chunks to new dimensions
    rechunk: a function to convert the blocks
        of an existing dask array to new chunks or blockshape
i    (   t   absolute_importt   divisiont   print_functionN(   t   productt   chaint   count(   t   getitemt   addt   mult
   itemgetter(   t
   accumulatet   reducei   (   t   tokenize(   t   HighLevelGraph(   t   parse_bytesi   (   t   concatenate3t   Arrayt   normalize_chunks(   t   validate_axis(   t   empty(   t   configc      	   C` sD   g  |  D]9 } t  t | f d t | ƒ t t d | ƒ ƒ ƒ ^ q S(   sê    Internal utility for cumulative sum with label.

    >>> cumdims_label(((5, 3, 3), (2, 2, 1)), 'n')  # doctest: +NORMALIZE_WHITESPACE
    [(('n', 0), ('n', 5), ('n', 8), ('n', 11)),
     (('n', 0), ('n', 2), ('n', 4), ('n', 5))]
    i   i    (   i    (   t   tuplet   zipt   lenR
   R   (   t   chunkst   constt   bds(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   cumdims_label   s    c         C` s    t  t |  | d t d ƒ ƒƒ S(   sG  

    >>> new = cumdims_label(((2, 3), (2, 2, 1)), 'n')
    >>> old = cumdims_label(((2, 2, 1), (5,)), 'o')

    >>> _breakpoints(new[0], old[0])
    (('n', 0), ('o', 0), ('n', 2), ('o', 2), ('o', 4), ('n', 5), ('o', 5))
    >>> _breakpoints(new[1], old[1])
    (('n', 0), ('o', 0), ('n', 2), ('n', 4), ('n', 5), ('o', 5))
    t   keyi   (   R   t   sortedR	   (   t   cumoldt   cumnew(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   _breakpoints)   s    c         C` s#  d } d } d } g  } g  } xè t  d t |  ƒ ƒ D]Ñ } |  | \ } } |  | d \ }	 }
 |	 d k r‰ | r‰ | j | ƒ g  } q‰ n  |	 d k rž d } n | } | |
 | } | } | |
 k rÊ q4 n  | j | t | | ƒ f ƒ | d k r4 | d 7} d } q4 q4 W| r| j | ƒ n  | S(   sB  
    Internal utility to intersect chunks for 1d after preprocessing.

    >>> new = cumdims_label(((2, 3), (2, 2, 1)), 'n')
    >>> old = cumdims_label(((2, 2, 1), (5,)), 'o')

    >>> _intersect_1d(_breakpoints(old[0], new[0]))  # doctest: +NORMALIZE_WHITESPACE
    [[(0, slice(0, 2, None))],
     [(1, slice(0, 2, None)), (2, slice(0, 1, None))]]
    >>> _intersect_1d(_breakpoints(old[1], new[1]))  # doctest: +NORMALIZE_WHITESPACE
    [[(0, slice(0, 2, None))],
     [(0, slice(2, 4, None))],
     [(0, slice(4, 5, None))]]

    Parameters
    ----------

    breaks: list of tuples
        Each tuple is ('o', 8) or ('n', 8)
        These are pairs of 'o' old or new 'n'
        indicator with a corresponding cumulative sum.

    Uses 'o' and 'n' to make new tuples of slices for
    the new block crosswalk to old blocks.
    i    i   t   nt   o(   t   rangeR   t   appendt   slice(   t   breakst   startt   last_endt   old_idxt   rett   ret_nextt   idxt   labelt   brt
   last_labelt   last_brt   end(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   _intersect_1d7   s4    	
c         C` sð  g  |  D]" } t  d „  | Dƒ ƒ s | ^ q } g  | D]" } t  d „  | Dƒ ƒ s6 | ^ q6 } g  |  D] } t d „  | Dƒ ƒ ^ qe } g  | D] } t d „  | Dƒ ƒ ^ qŽ } t | d ƒ } t | d ƒ } g  | D] }	 t |	 ƒ ^ qÕ }
 g  | D] } t | ƒ ^ qô } |
 | k s1t d |
 | f ƒ ‚ n  | | k sLt d ƒ ‚ n  g  t | | ƒ D]# } t t | d	 | d
 ƒ ƒ ^ q\} xd t | ƒ D]V \ } } | r’g  t | ƒ D] } | t	 d	 d ƒ f g ^ q±} | j | | ƒ q’q’W| S(   sÍ   Helper to build old_chunks to new_chunks.

    Handles missing values, as long as the missing dimension
    is unchanged.

    Examples
    --------
    >>> old = ((10, 10, 10, 10, 10), )
    >>> new = ((25, 5, 20), )
    >>> _old_to_new(old, new)  # doctest: +NORMALIZE_WHITESPACE
    [[[(0, slice(0, 10, None)), (1, slice(0, 10, None)), (2, slice(0, 5, None))],
      [(2, slice(5, 10, None))],
      [(3, slice(0, 10, None)), (4, slice(0, 10, None))]]]
    c         s` s   |  ] } t  j | ƒ Vq d  S(   N(   t   matht   isnan(   t   .0t   y(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>   s    c         s` s   |  ] } t  j | ƒ Vq d  S(   N(   R3   R4   (   R5   R6   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>€   s    c         s` s   |  ] } t  j | ƒ Vq d  S(   N(   R3   R4   (   R5   R6   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>‚   s    c         s` s   |  ] } t  j | ƒ Vq d  S(   N(   R3   R4   (   R5   R6   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>ƒ   s    R"   R!   s&   Cannot change dimensions from %r to %rs2   Chunks must be unchanging along unknown dimensionsi    i   N(   t   anyt   sumR   t
   ValueErrorR   R2   R    t	   enumerateR#   R%   t   Nonet   insert(   t
   old_chunkst
   new_chunkst   xt	   old_knownt	   new_knownt	   n_missingt
   n_missing2t   cmot   cmnR"   t   sumsR!   t   sums2t   cmt
   old_to_newR,   t   missingt   it   extra(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   _old_to_newp   s$    //))91c         C` s5   t  |  | ƒ } t | Œ  } t d „  | Dƒ ƒ } | S(   sÆ  
    Make dask.array slices as intersection of old and new chunks.

    >>> intersections = intersect_chunks(((4, 4), (2,)),
    ...                                  ((8,), (1, 1)))
    >>> list(intersections)  # doctest: +NORMALIZE_WHITESPACE
    [(((0, slice(0, 4, None)), (0, slice(0, 1, None))),
      ((1, slice(0, 4, None)), (0, slice(0, 1, None)))),
     (((0, slice(0, 4, None)), (0, slice(1, 2, None))),
      ((1, slice(0, 4, None)), (0, slice(1, 2, None))))]

    Parameters
    ----------

    old_chunks : iterable of tuples
        block sizes along each dimension (convert from old_chunks)
    new_chunks: iterable of tuples
        block sizes along each dimension (converts to new_chunks)
    c         s` s!   |  ] } t  t | Œ  ƒ Vq d  S(   N(   R   R   (   R5   t   cr(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>°   s    (   RM   R   R   (   R=   R>   RI   t   cross1t   cross(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   intersect_chunks™   s    c      	   ` sÁ  t  | t ƒ rh ‡  f d †  | j ƒ  Dƒ } x: t ˆ  j ƒ D]& } | | k r; ˆ  j | | | <q; q; Wn  t  | t t f ƒ r¢ t d „  t | ˆ  j ƒ Dƒ ƒ } n  t	 | ˆ  j
 d | d ˆ  j d ˆ  j ƒ} | ˆ  j k rß ˆ  Sˆ  j } t | ƒ | k s	t d ƒ ‚ n  t t t | ƒ ƒ } x[ t | ˆ  j
 ƒ D]G \ } } | | k r1t j | ƒ r1t j | ƒ r1t d ƒ ‚ q1q1Wt ˆ  j | ˆ  j j | | ƒ }	 x |	 D] }
 t ˆ  |
 ƒ ‰  q¤Wˆ  S(   sV  
    Convert blocks in dask array x for new chunks.

    Parameters
    ----------
    x: dask array
        Array to be rechunked.
    chunks:  int, tuple or dict
        The new block dimensions to create. -1 indicates the full size of the
        corresponding dimension.
    threshold: int
        The graph growth factor under which we don't bother introducing an
        intermediate step.
    block_size_limit: int
        The maximum block size (in bytes) we want to produce
        Defaults to the configuration value ``array.chunk-size``

    Examples
    --------
    >>> import dask.array as da
    >>> x = da.ones((1000, 1000), chunks=(100, 100))

    Specify uniform chunk sizes with a tuple

    >>> y = x.rechunk((1000, 10))

    Or chunk only specific dimensions with a dictionary

    >>> y = x.rechunk({0: 1000})

    Use the value ``-1`` to specify that you want a single chunk along a
    dimension or the value ``"auto"`` to specify that dask can freely rechunk a
    dimension to attain blocks of a uniform block size

    >>> y = x.rechunk({0: -1, 1: 'auto'}, block_size_limit=1e8)
    c         ` s+   i  |  ]! \ } } | t  | ˆ  j ƒ “ q S(    (   R   t   ndim(   R5   t   ct   v(   R?   (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys
   <dictcomp>Ú   s   	 c         s` s-   |  ]# \ } } | d  k	 r! | n | Vq d  S(   N(   R;   (   R5   t   lct   rc(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>ß   s   t   limitt   dtypet   previous_chunkss-   Provided chunks are not consistent with shape(   t
   isinstancet   dictt   itemsR#   RR   R   R   t   listR   R   t   shapeRX   R   R9   t   mapR8   R3   R4   t   plan_rechunkt   itemsizet   _compute_rechunk(   R?   R   t	   thresholdt   block_size_limitRK   RR   t
   new_shapest   newt   oldt   stepsRS   (    (   R?   s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   rechunk´   s0    %		,c         C` s   t  t t t |  ƒ ƒ S(   N(   R   R   R_   R   (   R   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   _number_of_blocks÷   s    c         C` s   t  t t t |  ƒ ƒ S(   N(   R   R   R_   t   max(   R   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   _largest_block_sizeû   s    c         C` s&   t  t d „  t |  | ƒ Dƒ ƒ } | S(   s;    Estimate the graph size during a rechunk computation.
    c         s` s+   |  ]! \ } } t  | ƒ t  | ƒ Vq d  S(   N(   R   (   R5   t   oct   nc(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>  s   (   R   R   R   (   R=   R>   t   crossed_size(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   estimate_graph_sizeÿ   s    c         C` sˆ   g  } xu |  D]m } t  t j | | ƒ ƒ } x9 t | ƒ D]+ } | | | } | j | ƒ | | 8} q9 W| d k s t ‚ q Wt | ƒ S(   sq    Minimally divide the given chunks so as to make the largest chunk
    width less or equal than *max_width*.
    i    (   t   intt   npt   ceilR#   R$   t   AssertionErrorR   (   t   desired_chunkst	   max_widthR   RS   t
   nb_dividesRK   R!   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   divide_to_width	  s    c         C` s8  t  |  ƒ | k r |  St |  ƒ } t  | ƒ d k rž | j ƒ  } t  |  ƒ } | | } | | } | | | } | | | | } | | f | | f | | St |  ƒ | } t  |  ƒ | }	 g  t t  |  ƒ d ƒ D]) }
 |  |
 |  |
 d |
 |
 d f ^ qÕ } t j | ƒ t |  ƒ } x|	 d k r$t j | ƒ \ } }
 } | | d k rª| d 7} x | | d k r~| d 7} qaWt j	 | | |
 | | |
 | f ƒ q nC | |
 | | | k rít j	 | | |
 | | |
 | f ƒ q n  | |
 d k st
 ‚ d | |
 <| | | <|	 d 8}	 q Wt t d | ƒ ƒ S(   s…    Minimally merge the given chunks so as to drop the number of
    chunks below *max_number*, while minimizing the largest width.
    i   i    N(   R   t   sett   popR8   R#   t   heapqt   heapifyR]   t   heappopt   heappushRt   R   t   filterR;   (   Ru   t
   max_numbert   distinctt   wR!   t   totalt   desired_widtht   widtht   adjustt   nmergesRK   t   heapR   t   j(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   merge_to_number  sB    

C
%%

c         ` sú  t  |  ƒ } g  |  D] } t | ƒ ^ q ‰ g  | D] } t | ƒ ^ q2 ‰ d „  t t |  | ƒ ƒ Dƒ ‰ ‡ ‡ f d †  t | ƒ Dƒ ‰  g  t | ƒ D] } ˆ | d k r• | ^ q• } ‡  ‡ f d †  } t | d | ƒ} t t ˆ ƒ }	 t |  ƒ }
 t	 } xÁ | D]¹ } |	 ˆ | ˆ | p!d } | | k rH| | |
 | <| }	 qˆ | } t
 | | |	 ƒ } t | | | ƒ } t  | ƒ t  |  | ƒ k r¶| |
 | <|	 t | ƒ | }	 n  t } qW|	 t |
 ƒ k sØt ‚ |	 | k sêt ‚ t |
 ƒ | f S(   sÒ   
    Find an intermediate rechunk that would merge some adjacent blocks
    together in order to get us nearer the *new_chunks* target, without
    violating the *block_size_limit* (in number of elements).
    c         S` s5   i  |  ]+ \ } \ } } t  | ƒ t  | ƒ | “ q S(    (   R   (   R5   t   dimRm   Rn   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys
   <dictcomp>X  s   	c         ` s+   i  |  ]! } ˆ  | ˆ | p  d  | “ q S(   i   (    (   R5   R‹   (   t   new_largest_widtht   old_largest_width(    s1   lib/python2.7/site-packages/dask/array/rechunk.pys
   <dictcomp>]  s   	g      ð?c         ` sS   ˆ |  } ˆ  |  } | d k r) d } n  | d k rO t  j | ƒ t  j | ƒ Sd S(   Ni   g•Ö&è.>i    g0¸D   ð?(   Rr   t   log(   t   kt   gset   bse(   t   block_size_effectt   graph_size_effect(    s1   lib/python2.7/site-packages/dask/array/rechunk.pyR   m  s
    

	R   i   (   R   Rk   R:   R   R#   R   R   R   R]   t   FalseRq   Rx   t   TrueRl   Rt   R   (   R=   R>   Rd   RR   RS   R‹   t   merge_candidatesR   t   sorted_candidatest   largest_block_sizeR   t   memory_limit_hitt   new_largest_block_sizet   largest_widtht   chunk_limit(    (   R’   R“   RŒ   R   s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   find_merge_rechunkL  s:    	


c   	      C` s  t  |  ƒ } t |  ƒ } xç t | ƒ D]Ù } t | | ƒ } | | k rJ Pn  t  |  | ƒ t  | | ƒ k rp q% n  t t  |  | ƒ | | ƒ } t | | | ƒ } t  | ƒ | k s¹ t ‚ t  | ƒ t  |  | ƒ k r% t | ƒ t |  | ƒ k r% | | | <q% q% Wt | ƒ S(   s   
    Find an intermediate rechunk that would split some chunks to
    get us nearer *new_chunks*, without violating the *graph_size_limit*.
    (	   R   R]   R#   Rp   Rq   RŠ   Rt   Rk   R   (	   R=   R>   t   graph_size_limitRR   R   R‹   t
   graph_sizeR€   RS   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   find_split_rechunk•  s     8c         C` sÊ  | p t  j d ƒ } | p' t  j d ƒ } t | t ƒ rH t | ƒ } n  t | ƒ } g  } g  |  D] } t d „  | Dƒ ƒ ^ qa } | d k s¨ t | ƒ s¨ t | ƒ r³ | | g S| | } t |  ƒ }	 t | ƒ }
 t	 | |	 |
 g ƒ } | t
 |  ƒ t
 | ƒ } |  } t } x¬ t r¾t | | ƒ } | | k  r8Pn  | rG| } n t | | | | ƒ } t | | | ƒ \ } } | | k rˆ| s”| | k r˜Pn  | j | ƒ | } | sµPn  t } qW| | g S(   s4   Plan an iterative rechunking from *old_chunks* to *new_chunks*.
    The plan aims to minimize the rechunk graph size.

    Parameters
    ----------
    itemsize: int
        The item size of the array
    threshold: int
        The graph growth factor under which we don't bother
        introducing an intermediate step
    block_size_limit: int
        The maximum block size (in bytes) we want to produce during an
        intermediate step

    Notes
    -----
    No intermediate steps will be planned if any dimension of ``old_chunks``
    is unknown.
    s   array.rechunk-thresholds   array.chunk-sizec         s` s   |  ] } t  j | ƒ Vq d  S(   N(   R3   R4   (   R5   R6   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>Î  s    i   (   R   t   getRZ   t   strR   R   R7   t   allRl   Rk   Rj   R•   Rp   R    R   R$   R”   (   R=   R>   Ra   Rc   Rd   RR   Rh   R?   t   has_nanst   largest_old_blockt   largest_new_blockt   graph_size_thresholdt   current_chunkst
   first_passRŸ   R   R™   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyR`   ±  sJ    )%
				
c         ` s  ˆ  j  d k r+ t ˆ  j d | d ˆ  j ƒSˆ  j } t ˆ  j | ƒ } t ƒ  } t ƒ  } t ˆ  | ƒ } d | } d | } t	 ƒ  }	 t
 j g  ˆ  j D] }
 t |
 ƒ ^ q” d d ƒ} x. t
 j | j ƒ D] } ˆ  j f | | | <qÈ Wt d „  | Dƒ Œ  } x¹t | | ƒ D]¨\ } } | f | } g  t | ƒ D]' } g  | D] } | | d ^ q?^ q2} g  t | ƒ D] } t t | | ƒ ƒ ^ ql} t
 j | d d ƒ} | j } x© t | ƒ D]› \ } } t | Œ  \ } } | t |	 ƒ f } | | d } t ‡  f d	 †  t t | | ƒ ƒ Dƒ ƒ r3| | | | <q¹t | | | f | | <| | | <q¹W| | j  d k sqt ‚ t d
 „  | j Dƒ ƒ rž| j d | | <qt | j ƒ  f | | <qW~ ~ t j | | ƒ } t j | | d ˆ  g ƒ} t | | | d ˆ  j ƒS(   s7    Compute the rechunk of *x* to the given *chunks*.
    i    R   RX   s   rechunk-merge-s   rechunk-split-t   Oc         s` s!   |  ] } t  t | ƒ ƒ Vq d  S(   N(   R#   R   (   R5   RS   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>  s    i   c         3` sD   |  ]: \ } \ } } | j  d  k o; | j ˆ  j | | k Vq d S(   i    N(   R'   t   stopR   (   R5   RK   t   slct   ind(   R?   (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>)  s   c         s` s   |  ] } | d  k Vq d S(   i   N(    (   R5   t   d(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>3  s    t   dependencies(   t   sizeR   R^   RX   RR   RQ   R   R[   R   R   Rr   R   t   ndindext   nameR   R   R#   Ry   t   flatR:   t   nextR£   R   Rt   R   t   tolistt   toolzt   mergeR   t   from_collectionsR   (   R?   R   RR   t   crossedt   x2t   intermediatest   tokent
   merge_namet
   split_namet   split_name_suffixesRS   t
   old_blockst   indext	   new_indext   new_idxRO   R   RK   RN   t   old_block_indicest   subdims1t   rec_cat_argt   rec_cat_arg_flatt   rec_cat_indext
   ind_slicest   old_block_indext   slicesR²   t	   old_indext   layert   graph(    (   R?   s1   lib/python2.7/site-packages/dask/array/rechunk.pyRb     sL    			

	1:,	t   _PrettyBlocksc           B` s    e  Z d  „  Z d „  Z e Z RS(   c         C` s   | |  _  d  S(   N(   t   blocks(   t   selfRÐ   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   __init__A  s    c         C` s§  g  } g  } d } xÑ |  j  D]Æ } | r‡ | d | k r‡ | d k rz t | ƒ d k rz | j d  | d  f ƒ | d } n  | d 7} q | d k rÕ t | ƒ d k s« t ‚ | j | d | d f ƒ g  } d } n  | j | ƒ q W| rD| d k r| j d  | f ƒ qDt | ƒ d k s&t ‚ | j | d | d f ƒ n  g  } xM | D]E \ } } | d  k r| j t | ƒ ƒ qQ| j d | | f ƒ qQWd j | ƒ S(   Ni    iÿÿÿÿi   s   %d*[%s]s    | (   RÐ   R   R$   R;   Rt   R¢   t   join(   RÑ   t   runst   runt   repeatsRS   t   parts(    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   __str__D  s4    	(   t   __name__t
   __module__RÒ   RØ   t   __repr__(    (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyRÏ   ?  s   		 c         C` s5   t  |  t ƒ r% t d „  |  Dƒ ƒ s+ t ‚ t |  ƒ S(   sÔ   
    Pretty-format *blocks*.

    >>> format_blocks((10, 10, 10))
    3*[10]
    >>> format_blocks((2, 3, 4))
    [2, 3, 4]
    >>> format_blocks((10, 10, 5, 6, 2, 2, 2, 7))
    2*[10] | [5, 6] | 3*[2] | [7]
    c         s` s-   |  ]# } t  | t ƒ p$ t j | ƒ Vq d  S(   N(   RZ   Rq   R3   R4   (   R5   R?   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>s  s   (   RZ   R   R£   Rt   RÏ   (   RÐ   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   format_blocksg  s    	c         C` s)   t  |  t ƒ s t ‚ t d „  |  Dƒ ƒ S(   sH   
    >>> format_chunks((10 * (3,), 3 * (10,)))
    (10*[3], 3*[10])
    c         s` s   |  ] } t  | ƒ Vq d  S(   N(   RÜ   (   R5   RS   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pys	   <genexpr>~  s    (   RZ   R   Rt   (   R   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   format_chunksx  s    c         C` s   g  |  D] } t  | ƒ ^ q S(   ss   
    >>> format_plan([((10, 10, 10), (15, 15)), ((30,), (10, 10, 10))])
    [(3*[10], 2*[15]), ([30], 3*[10])]
    (   RÝ   (   t   planRS   (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   format_plan  s    (9   t   __doc__t
   __future__R    R   R   R3   R{   t	   itertoolsR   R   R   t   operatorR   R   R   R	   t   numpyRr   R¶   R
   R   t   baseR   t   highlevelgraphR   t   utilsR   t   coreR   R   R   R   t   wrapR   t    R   R   R    R2   RM   RQ   R;   Ri   Rj   Rl   Rp   Rx   RŠ   R   R    R`   Rb   t   objectRÏ   RÜ   RÝ   Rß   (    (    (    s1   lib/python2.7/site-packages/dask/array/rechunk.pyt   <module>   sF   "			9	)	C			
		4	I	O	=(			