Fix multiprocessing example when using Python 3

In Python 3, 'map' returns an object which evalutes the function as it is
consumed, not when 'map' is called. Therefore, the correct comparison to
pool.map(...) is list(map(...)).
This commit is contained in:
Ray Speth 2015-08-03 23:00:54 -04:00
parent 7ca9327f7d
commit 6514f7a8e1

View file

@ -64,11 +64,11 @@ def serial(mech, predicate, nTemps):
P = ct.one_atm
X = 'CH4:1.0, O2:1.0, N2:3.76'
init_process(mech)
y = map(predicate,
zip(itertools.repeat(mech),
np.linspace(300, 900, nTemps),
itertools.repeat(P),
itertools.repeat(X)))
y = list(map(predicate,
zip(itertools.repeat(mech),
np.linspace(300, 900, nTemps),
itertools.repeat(P),
itertools.repeat(X))))
return y
if __name__ == '__main__':