jangjusung / jusung-python

0 stars 0 forks source link

py #19

Open jangjusung opened 2 years ago

jangjusung commented 2 years ago

points=np.arange(-5,5,0.01) xs, ys =np.meshgrid(points,points)

z=np.sqrt(xs2+ys2)

import matplotlib.pyplot as plt plt.imshow (z, cmap=plt.cm.gray); plt.colorbal() plt.title("image plot of $\sqrt{x^2 + y^2}$ for a grid of values") z.shape

xarr=np.array([1.1,1.2,1.3,1.4,1.5]) yarr=np.array([2.1,2.2,2.3,2.4,2.5]) cond=np.array([True,False,True,True,False])

result = [(x if c else y) for x,y,c in zip(xarr,yarr,cond)] result

result = np.where(cond,xarr,yarr) result