def test_numpy_wrapper(): x = Array(np.random.randn(4).astype(object)) x[0] = get_tdict() x[1] = 0 assert x[1] == 0 x.begin() x[0].arr = x x[1] = 10 assert 'arr' in x[0] assert len(x[0].arr) == len(x) assert x[1] == 10 assert repr(x) == repr(json_unpack(json_pack(x))) x.abort() assert x[1] == 0 assert 'arr' not in x[0] assert repr(json_unpack(json_pack(x))) == repr(x)
def test_complex_array(): x = np.arange(3).astype(object) x[0] = get_tdict() p = json_pack(x) c = json_unpack(p) assert repr(x) == repr(c)
def test_json_pack_transactionable(): data = get_tdict() s = json_pack(data) assert repr(json_unpack(s)) == repr(data) data.begin() data[1234] = 'element' assert 1234 in data assert 'element' == data[1234] data.abc = 123 assert 'abc' in data assert data.abc == 123 assert data['abc'] == 123 data.abort() assert repr(json_unpack(s)) == repr(data)
def save(self): # returns string data = json_pack(self) # data = str(Packable.pack(self)) # print('key: {}'.format(self.RNG.random())) # testing return data
def test_numpy_arrays(): x = np.random.randn(10) p = json_pack(x) c = json_unpack(p) assert (c - x).sum() == 0
def save(self): return {user: json_pack(agent) for user, agent in self.agents.items()}