From 6514f7a8e1ba6aecf7496b13ec000eef81f92d40 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 3 Aug 2015 23:00:54 -0400 Subject: [PATCH] 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(...)). --- .../examples/transport/multiprocessing_viscosity.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py b/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py index 1556aafc0..a32d6ab6f 100644 --- a/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py +++ b/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py @@ -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__':