#NEWLINE# def _wrap( self , func , * args , **kwargs ) : #NEWLINE# #INDENT# size = kwargs . pop ( 'size' ) #NEWLINE# chunks = kwargs . pop ( 'chunks' ) #NEWLINE# if ( not isinstance ( size , ( tuple , list ) ) ) : #NEWLINE# #INDENT# size = ( size , ) #NEWLINE# #UNINDENT# chunks = normalize_chunks ( chunks , size ) #NEWLINE# kw = kwargs . copy ( ) #NEWLINE# kw [ 'size' ] = ( 0 , ) #NEWLINE# dtype = func ( np . random . RandomState ( ) , * args , ** kw ) . dtype #NEWLINE# sizes = list ( product ( * chunks ) ) #NEWLINE# seeds = different_seeds ( len ( sizes ) , self . _numpy_state ) #NEWLINE# token = tokenize ( seeds , size , chunks , args , kwargs ) #NEWLINE# name = 'da.random.{0}-{1}' . format ( func . __name__ , token ) #NEWLINE# keys = product ( [ name ] , * [ range ( len ( bd ) ) for bd in chunks ] ) #NEWLINE# vals = ( ( _apply_random , func . __name__ , seed , size , args , kwargs ) for ( seed , size ) in zip ( seeds , sizes ) ) #NEWLINE# dsk = dict ( zip ( keys , vals ) ) #NEWLINE# return Array ( dsk , name , chunks , dtype = dtype )