If I have a simple object like:
class Toy(object):
def __init__(self):
self.flag = 1
If I make 100 unique copies:
import numpy as np
from copy import deepcopy
t = Toy()
toys = np.array([deepcopy(t) for x in range(100)])
Is it possible to do a numpy operation on this that will change the flag like the following?
from random import randint
def deflag(x):
x.flag = randint(0,9)
return x
If I do a map operation like it works but it's not vectorized as far as I can tell.
deflagged = map(deflag, toys)