def test_encode_decode_roundtrip(): for dt in [np.float32, np.float64, np.int64]: for shape in [(12, ), (2, 6), (2, 2, 3)]: a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) aa = bus.decode_base64_dict(d) assert np.array_equal(a, aa)
def test_encode_decode_roundtrip(): for dt in [np.float32, np.float64, np.int64]: for shape in [(12,), (2, 6), (2,2,3)]: a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) aa = bus.decode_base64_dict(d) assert np.array_equal(a, aa)
def test_encode_base64_dict(dt, shape) -> None: a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) assert 'shape' in d assert d['shape'] == a.shape assert 'dtype' in d assert d['dtype'] == a.dtype.name assert '__ndarray__' in d b64 = base64.b64decode(d['__ndarray__']) aa = np.frombuffer(b64, dtype=d['dtype']) assert np.array_equal(a, aa)
def test_encode_base64_dict(dt, shape): a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) assert 'shape' in d assert d['shape'] == a.shape assert 'dtype' in d assert d['dtype'] == a.dtype.name assert '__ndarray__' in d b64 = base64.b64decode(d['__ndarray__']) aa = np.frombuffer(b64, dtype=d['dtype']) assert np.array_equal(a, aa)
def test_encode_base64_dict(): for dt in [np.float32, np.float64, np.int64]: for shape in [(12, ), (2, 6), (2, 2, 3)]: a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) assert 'shape' in d assert d['shape'] == a.shape assert 'dtype' in d assert d['dtype'] == a.dtype.name assert '__ndarray__' in d b64 = base64.b64decode(d['__ndarray__']) aa = np.fromstring(b64, dtype=d['dtype']) assert np.array_equal(a, aa)
def test_encode_base64_dict(): for dt in [np.float32, np.float64, np.int64]: for shape in [(12,), (2, 6), (2,2,3)]: a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) assert 'shape' in d assert d['shape'] == a.shape assert 'dtype' in d assert d['dtype'] == a.dtype.name assert '__ndarray__' in d b64 = base64.b64decode(d['__ndarray__']) aa = np.fromstring(b64, dtype=d['dtype']) assert np.array_equal(a, aa)
def test_encode_decode_roundtrip(dt, shape) -> None: a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) aa = bus.decode_base64_dict(d) assert np.array_equal(a, aa)
def test_encode_decode_roundtrip(dt, shape): a = np.arange(12, dtype=dt) a.reshape(shape) d = bus.encode_base64_dict(a) aa = bus.decode_base64_dict(d) assert np.array_equal(a, aa)