def test_store_zip_tsv_a(self) -> None: f1, f2, f3 = get_test_framesA() with temp_file('.zip') as fp: st = StoreZipTSV(fp) st.write((f.name, f) for f in (f1, f2, f3)) labels = tuple(st.labels(strip_ext=False)) self.assertEqual(labels, ('foo.txt', 'bar.txt', 'baz.txt')) for label, frame in ((f.name, f) for f in (f1, f2, f3)): for read_max_workers in (None, 1, 2): config = StoreConfig(index_depth=1, read_max_workers=read_max_workers) frame_stored = st.read(label, config=config) self.assertEqual(frame_stored.shape, frame.shape) self.assertTrue((frame_stored == frame).all().all()) self.assertEqual(frame.to_pairs(0), frame_stored.to_pairs(0)) frame_stored_2 = st.read(label, config=config, container_type=FrameGO) self.assertEqual(frame_stored_2.__class__, FrameGO) self.assertEqual(frame_stored_2.shape, frame.shape)
def test_store_zip_tsv_a(self) -> None: f1 = Frame.from_dict(dict(a=(1, 2), b=(3, 4)), index=('x', 'y'), name='foo') f2 = Frame.from_dict(dict(a=(1, 2, 3), b=(4, 5, 6)), index=('x', 'y', 'z'), name='bar') f3 = Frame.from_dict(dict(a=(10, 20), b=(50, 60)), index=('p', 'q'), name='baz') with temp_file('.zip') as fp: st = StoreZipTSV(fp) st.write((f.name, f) for f in (f1, f2, f3)) labels = tuple(st.labels(strip_ext=False)) self.assertEqual(labels, ('foo.txt', 'bar.txt', 'baz.txt')) config = StoreConfig(index_depth=1) for label, frame in ((f.name, f) for f in (f1, f2, f3)): frame_stored = st.read(label, config=config) self.assertEqual(frame_stored.shape, frame.shape) self.assertTrue((frame_stored == frame).all().all()) self.assertEqual(frame.to_pairs(0), frame_stored.to_pairs(0)) frame_stored_2 = st.read(label, config=config, container_type=FrameGO) self.assertEqual(frame_stored_2.__class__, FrameGO) self.assertEqual(frame_stored_2.shape, frame.shape)
def test_bus_init_a(self) -> None: f1 = Frame.from_dict(dict(a=(1, 2), b=(3, 4)), index=('x', 'y'), name='foo') f2 = Frame.from_dict(dict(a=(1, 2, 3), b=(4, 5, 6)), index=('x', 'y', 'z'), name='bar') config = StoreConfigMap.from_config(StoreConfig(index_depth=1)) b1 = Bus.from_frames((f1, f2), config=config) self.assertEqual(b1.keys().values.tolist(), ['foo', 'bar']) with temp_file('.zip') as fp: b1.to_zip_tsv(fp) b2 = Bus.from_zip_tsv(fp) f3 = b2['bar'] f4 = b2['foo'] # import ipdb; ipdb.set_trace() zs = StoreZipTSV(fp) zs.write(b1.items()) # how to show that this derived getitem has derived type? f3 = zs.read('foo', config=config['foo']) self.assertEqual(f3.to_pairs(0), (('a', (('x', 1), ('y', 2))), ('b', (('x', 3), ('y', 4)))))