Skip to content

Instantly share code, notes, and snippets.

@mluessi
Created September 13, 2012 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mluessi/3717046 to your computer and use it in GitHub Desktop.
Save mluessi/3717046 to your computer and use it in GitHub Desktop.
joblib_pull_44_retval
import numpy as np
from numpy.testing import assert_array_equal
from joblib import Parallel, delayed
n_jobs = 4
n_megabytes = 10
def silly_function(vec, c):
#val = float(c * np.mean(vec)) # works
val = c * np.mean(vec) # does not work
return val
vec = np.random.rand(2 ** 20 * n_megabytes / 8)
out = np.array(Parallel(n_jobs=n_jobs, verbose=5)(delayed(silly_function)(vec, c) for c in
np.arange(n_jobs)))
out2 = np.array([silly_function(vec, c) for c in np.arange(n_jobs)])
assert_array_equal(out, out2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment