def test_03_05_json_encode_uint64(self): for dtype in np.uint64, np.int64, np.uint32: json_string, buf = Z.json_encode( dict(foo = np.arange(10).astype(dtype))) result = Z.json_decode(json_string, buf) self.assertEqual(result["foo"].dtype, np.int32) json_string, buf = Z.json_encode( dict(foo=np.arange(10).astype(np.int16))) result = Z.json_decode(json_string, buf) self.assertEqual(result["foo"].dtype, np.int16)
def test_03_05_json_encode_uint64(self): for dtype in np.uint64, np.int64, np.uint32: json_string, buf = Z.json_encode( dict(foo=np.arange(10).astype(dtype))) result = Z.json_decode(json_string, buf) self.assertEqual(result["foo"].dtype, np.int32) json_string, buf = Z.json_encode( dict(foo=np.arange(10).astype(np.int16))) result = Z.json_decode(json_string, buf) self.assertEqual(result["foo"].dtype, np.int16)
def test_03_04_json_encode(self): r = np.random.RandomState() r.seed(15) test_cases = [{ "k": "v" }, { "k": (1, 2, 3) }, { (1, 2, 3): "k" }, { 1: { u"k": "v" } }, { "k": [{ 1: 2 }, { 3: 4 }] }, { "k": ((1, 2, { "k1": "v1" }), ) }, { "k": r.uniform(size=(5, 8)) }, { "k": r.uniform(size=(7, 3)) > .5 }] for test_case in test_cases: json_string, buf = Z.json_encode(test_case) result = Z.json_decode(json_string, buf) self.same(test_case, result)
def test_03_04_json_encode(self): r = np.random.RandomState() r.seed(15) test_cases = [ { "k":"v" }, { "k":(1, 2, 3) }, { (1, 2, 3): "k" }, { 1: { u"k":"v" } }, { "k": [ { 1:2 }, { 3:4}] }, { "k": ( (1, 2 ,{ "k1":"v1" }), )}, { "k": r.uniform(size=(5, 8)) }, { "k": r.uniform(size=(7, 3)) > .5 } ] for test_case in test_cases: json_string, buf = Z.json_encode(test_case) result = Z.json_decode(json_string, buf) self.same(test_case, result)
def test_03_06_json_encode_zero_length_uint(self): for dtype in np.uint64, np.int64, np.uint32: json_string, buf = Z.json_encode( dict(foo = np.zeros(0,dtype))) result = Z.json_decode(json_string, buf) self.assertEqual(len(result["foo"]), 0)
def test_03_06_json_encode_zero_length_uint(self): for dtype in np.uint64, np.int64, np.uint32: json_string, buf = Z.json_encode(dict(foo=np.zeros(0, dtype))) result = Z.json_decode(json_string, buf) self.assertEqual(len(result["foo"]), 0)