properties - How to use ipyparallel for creating objects with @property -
my question related monte carlo method used in class decorated @property , want take advantage of ipyparallel. please find below minimal example showing essence of trying accomplish.
class my_pi: def __init__(self, num_points): self.num_points = num_points @property def pi(self): hits_inside_circle = 0 ii in range(self.num_points): x = random.random() y = random.random() if x**2+y**2 <= 1: hits_inside_circle += 1 pi = hits_inside_circle/self.num_points * 4 return pi pi = my_pi(1000000) import ipyparallel clients = ipyparallel.client() dview = clients[:] then stuck. how use dview on my_pi objects? pi.pi not callable, because property. know separete object initialization , use pi method pi.pi() want use @property.
best
Comments
Post a Comment