对于给定的两个离散函数,如下所示:
import myClass
from multiprocessing import Pool
def getForAll(elements):
pool = Pool()
return pool.map(myClass.doThing, elements)
要获得最多的最短的Python代码是什么?
答案 0 :(得分:3)
类似的东西:
<table *ngIf="visible">
Table content
</table>
答案 1 :(得分:1)
好吧,您只需要在y值上使用内置的max
函数即可。
f1max = max([y1(x) for x in x1])
f2max = max([y2(x) for x in x2])
答案 2 :(得分:0)
我会这样:
#!/usr/bin/env ipython
# -------------------
import numpy as np
import matplotlib as mpl
mpl.use('TKAgg');
from pylab import plot,show
# ---------------------
y1 = lambda(x): x**2
y2 = lambda(x): (x-1.5)*10
x1 = np.linspace(0,12,50)
x2 = np.linspace(1,10,12)
# --------------------
ymax=np.max((y1(x1),y2(x1)),axis=0)
plot(x1, y1(x1), '.-')
plot(x2, y2(x2), '.-')
plot(x1, ymax, 'k',lw=2.0)
show()