def from_zip_pickle(cls, fp: PathSpecifier, config: StoreConfigMapInitializer = None) -> 'Bus': store = StoreZipPickle(fp) return cls(cls._deferred_series(store.labels()), store=store, config=config)
def test_store_zip_pickle_a(self) -> None: f1, f2, f3 = get_test_framesA() with temp_file('.zip') as fp: st = StoreZipPickle(fp) st.write((f.name, f) for f in (f1, f2, f3)) labels = tuple(st.labels(strip_ext=False)) self.assertEqual(labels, ('foo.pickle', 'bar.pickle', 'baz.pickle')) for label, frame in ((f.name, f) for f in (f1, f2, f3)): frame_stored = st.read(label) 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, container_type=FrameGO) self.assertEqual(frame_stored_2.__class__, FrameGO) self.assertEqual(frame_stored_2.shape, frame.shape) frame_stored_3 = st.read(label, container_type=FrameHE) self.assertEqual(frame_stored_3.__class__, FrameHE) self.assertEqual(frame_stored_3.shape, frame.shape)
def test_store_zip_pickle_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 = StoreZipPickle(fp) st.write((f.name, f) for f in (f1, f2, f3)) labels = tuple(st.labels(strip_ext=False)) self.assertEqual(labels, ('foo.pickle', 'bar.pickle', 'baz.pickle')) for label, frame in ((f.name, f) for f in (f1, f2, f3)): frame_stored = st.read(label) 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, container_type=FrameGO) self.assertEqual(frame_stored_2.__class__, FrameGO) self.assertEqual(frame_stored_2.shape, frame.shape)
def test_store_zip_pickle_d(self) -> None: f1, *_ = get_test_framesA() with temp_file('.zip') as fp: for read_max_workers in (1, 2): config = StoreConfig( index_depth=1, include_index=True, label_encoder=lambda x: x.upper(), #type: ignore label_decoder=lambda x: x.lower(), read_max_workers=read_max_workers, ) st = StoreZipPickle(fp) st.write(((f1.name, f1), ), config=config) frame_stored = st.read(f1.name, config=config) self.assertEqual(tuple(st.labels()), ('FOO', )) self.assertEqual(tuple(st.labels(config=config)), ('foo', ))