Revision history [back]

Parallel Interface to the Sage interpreter

I am using the PSage() parallel interpreter as described here http://doc.sagemath.org/html/en/reference/interfaces/sage/interfaces/psage.html#sage-interfaces-psage. The interface works fine to evaluate multiple instances of function calls to functions of one or more scalar variables, however, if a function variable is array-like, the interface doesn't seem to work any more. I wonder if any special quoting is necessary for array-like arguments. Here is a minimal example. For reference, I copy the example from the above page, which works just fine, factor() has a single scalar variable.

v = [PSage() for _ in range(3)]
w = [x('factor(2^%s-1)'% randint(250,310)) for x in v]
w
[4057 * 8191 * 6740339310641 * 3340762283952395329506327023033,
31 * 13367 * 2940521 * 164511353 * 70171342151 *
3655725065508797181674078959681,
31 * 13367 * 2940521 * 164511353 * 70171342151 *
3655725065508797181674078959681]


However, the rosen() function with a single array-like/vector argument doesn't seem to work in the parallel interface. (The example below just calculates the same function value three times, but that is not the point here.)

from scipy.optimize import rosen

x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
rosen(x0)
848.22000000000003

v = [PSage() for _ in range(3)]
w = [x('rosen(x0)') for x in v]
w
[Sage, Sage, Sage]


Does anyone have any suggestion?