def apply_parallel(function, array, chunks=None, depth=0, mode=None, extra_arguments=(), extra_keywords={}):
 if (not dask_available):
  raise RuntimeError("Could not import 'dask'.  Please install using 'pip install dask'")
 if (chunks is None):
  shape = array.shape
  try:
   ncpu = cpu_count()
  except NotImplementedError:
   ncpu = 4
  chunks = _get_chunks(shape, ncpu)
 if (mode == 'wrap'):
  mode = 'periodic'
 elif (mode == 'symmetric'):
  mode = 'reflect'
 elif (mode == 'edge'):
  mode = 'nearest'
 def wrapped_func(arr):
  return function(arr, *extra_arguments, **extra_keywords)
 darr = da.from_array(array, chunks=chunks)
 return darr.map_overlap(wrapped_func, depth, boundary=mode).compute()

def apply_parallel ( function , array , chunks = None , depth = 0 , mode = None , extra_arguments = ( ) , extra_keywords = { } ) : if ( not dask_available ) : raise RuntimeError ( "Could not import 'dask'.  Please install using 'pip install dask'" ) if ( chunks is None ) : shape = array . shape try : ncpu = cpu_count ( ) except NotImplementedError : ncpu = 4 chunks = _get_chunks ( shape , ncpu ) if ( mode == 'wrap' ) : mode = 'periodic' elif ( mode == 'symmetric' ) : mode = 'reflect' elif ( mode == 'edge' ) : mode = 'nearest' def wrapped_func ( arr ) : return function ( arr , * extra_arguments , ** extra_keywords ) darr = da . from_array ( array , chunks = chunks ) return darr . map_overlap ( wrapped_func , depth , boundary = mode ) . compute ( )
map a function in parallel across an array .