def test_store_zip_csv_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 = StoreZipCSV(fp) st.write((f.name, f) for f in (f1, f2, f3)) labels = tuple(st.labels(strip_ext=False)) self.assertEqual(labels, ('foo.csv', 'bar.csv', 'baz.csv')) 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))
def test_store_zip_csv_b(self) -> None: f1, *_ = get_test_framesA() with temp_file('.zip') as fp: st = StoreZipCSV(fp) st.write((f.name, f) for f in (f1,)) # this now uses a default config f = st.read(f1.name) self.assertEqual(f.to_pairs(), (('__index0__', ((0, 'x'), (1, 'y'))), ('a', ((0, 1), (1, 2))), ('b', ((0, 3), (1, 4)))))
def test_store_zip_csv_b(self) -> None: f1 = Frame.from_dict(dict(a=(1, 2), b=(3, 4)), index=('x', 'y'), name='foo') with temp_file('.zip') as fp: st = StoreZipCSV(fp) st.write((f.name, f) for f in (f1, )) with self.assertRaises(ErrorInitStore): # config is required _ = st.read(f1.name)
def test_store_zip_csv_a(self) -> None: f1, f2, f3 = get_test_framesA() with temp_file('.zip') as fp: st = StoreZipCSV(fp) st.write((f.name, f) for f in (f1, f2, f3)) labels = tuple(st.labels(strip_ext=False)) self.assertEqual(labels, ('foo.csv', 'bar.csv', 'baz.csv')) for label, frame in ((f.name, f) for f in (f1, f2, f3)): for read_max_workers in (1, 2): config = StoreConfig(index_depth=1, read_max_workers=1) 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))