def test_simple_case(self): lists = [[0], [1.125, 1.25]] packed, offset = util.pack_arrays(lists) assert list(offset) == [0, 1, 3] assert list(packed) == [0, 1.125, 1.25] returned = util.unpack_arrays(packed, offset) for a1, a2 in itertools.zip_longest(lists, returned): assert a1 == list(a2)
def test_simple_case(self): lists = [[0], [1.125, 1.25]] packed, offset = util.pack_arrays(lists) self.assertEqual(list(offset), [0, 1, 3]) self.assertEqual(list(packed), [0, 1.125, 1.25]) returned = util.unpack_arrays(packed, offset) for a1, a2 in itertools.zip_longest(lists, returned): self.assertEqual(a1, list(a2))
def verify_packing(self, data): packed, offset = util.pack_arrays(data) assert packed.dtype == np.float64 assert offset.dtype == np.uint32 assert packed.shape[0] == offset[-1] returned = util.unpack_arrays(packed, offset) for a1, a2 in itertools.zip_longest(data, returned): assert np.array_equal(a1, a2) return returned
def verify_packing(self, data): packed, offset = util.pack_arrays(data) self.assertEqual(packed.dtype, np.float64) self.assertEqual(offset.dtype, np.uint32) self.assertEqual(packed.shape[0], offset[-1]) returned = util.unpack_arrays(packed, offset) for a1, a2 in itertools.zip_longest(data, returned): self.assertTrue(np.array_equal(a1, a2)) return returned