(tempdir, compression, dataset_reader)
| 3738 | "brotli" # not supported |
| 3739 | ]) |
| 3740 | def test_feather_format_compressed(tempdir, compression, dataset_reader): |
| 3741 | table = pa.table({'a': pa.array([0]*300, type="int8"), |
| 3742 | 'b': pa.array([.1, .2, .3]*100, type="float64")}) |
| 3743 | if not pa.Codec.is_available(compression): |
| 3744 | pytest.skip() |
| 3745 | |
| 3746 | basedir = tempdir / "feather_dataset_compressed" |
| 3747 | basedir.mkdir() |
| 3748 | file_format = ds.IpcFileFormat() |
| 3749 | |
| 3750 | uncompressed_basedir = tempdir / "feather_dataset_uncompressed" |
| 3751 | uncompressed_basedir.mkdir() |
| 3752 | ds.write_dataset( |
| 3753 | table, |
| 3754 | str(uncompressed_basedir / "data.arrow"), |
| 3755 | format=file_format, |
| 3756 | file_options=file_format.make_write_options(compression=None) |
| 3757 | ) |
| 3758 | |
| 3759 | if compression == "brotli": |
| 3760 | with pytest.raises(ValueError, match="Compression type"): |
| 3761 | write_options = file_format.make_write_options( |
| 3762 | compression=compression) |
| 3763 | with pytest.raises(ValueError, match="Compression type"): |
| 3764 | codec = pa.Codec(compression) |
| 3765 | write_options = file_format.make_write_options(compression=codec) |
| 3766 | return |
| 3767 | |
| 3768 | write_options = file_format.make_write_options(compression=compression) |
| 3769 | ds.write_dataset( |
| 3770 | table, |
| 3771 | str(basedir / "data.arrow"), |
| 3772 | format=file_format, |
| 3773 | file_options=write_options |
| 3774 | ) |
| 3775 | |
| 3776 | dataset = ds.dataset(basedir, format=ds.IpcFileFormat()) |
| 3777 | result = dataset_reader.to_table(dataset) |
| 3778 | assert result.equals(table) |
| 3779 | |
| 3780 | compressed_file = basedir / "data.arrow" / "part-0.arrow" |
| 3781 | compressed_size = compressed_file.stat().st_size |
| 3782 | uncompressed_file = uncompressed_basedir / "data.arrow" / "part-0.arrow" |
| 3783 | uncompressed_size = uncompressed_file.stat().st_size |
| 3784 | assert compressed_size < uncompressed_size |
| 3785 | |
| 3786 | |
| 3787 | def _create_parquet_dataset_simple(root_path): |
nothing calls this directly
no test coverage detected