|
5 | 5 | import pandas as pd
|
6 | 6 | import pyarrow as pa
|
7 | 7 | import pyarrow.parquet as pq
|
8 |
| -import pytest |
9 | 8 |
|
10 | 9 | from hats.io import file_io, paths
|
11 |
| -from hats.io.parquet_metadata import ( |
12 |
| - aggregate_column_statistics, |
13 |
| - read_row_group_fragments, |
14 |
| - row_group_stat_single_value, |
15 |
| - write_parquet_metadata, |
16 |
| -) |
| 10 | +from hats.io.parquet_metadata import aggregate_column_statistics, write_parquet_metadata |
17 | 11 |
|
18 | 12 |
|
19 | 13 | def test_write_parquet_metadata(tmp_path, small_sky_dir, small_sky_schema, check_parquet_schema):
|
@@ -126,24 +120,6 @@ def test_write_index_parquet_metadata(tmp_path, check_parquet_schema):
|
126 | 120 | )
|
127 | 121 |
|
128 | 122 |
|
129 |
| -def test_row_group_fragments(small_sky_order1_dir): |
130 |
| - partition_info_file = paths.get_parquet_metadata_pointer(small_sky_order1_dir) |
131 |
| - |
132 |
| - num_row_groups = 0 |
133 |
| - for _ in read_row_group_fragments(partition_info_file): |
134 |
| - num_row_groups += 1 |
135 |
| - |
136 |
| - assert num_row_groups == 4 |
137 |
| - |
138 |
| - |
139 |
| -def test_row_group_fragments_with_dir(small_sky_order1_dir): |
140 |
| - num_row_groups = 0 |
141 |
| - for _ in read_row_group_fragments(small_sky_order1_dir): |
142 |
| - num_row_groups += 1 |
143 |
| - |
144 |
| - assert num_row_groups == 4 |
145 |
| - |
146 |
| - |
147 | 123 | def test_aggregate_column_statistics(small_sky_order1_dir):
|
148 | 124 | partition_info_file = paths.get_parquet_metadata_pointer(small_sky_order1_dir)
|
149 | 125 |
|
@@ -193,83 +169,3 @@ def test_aggregate_column_statistics_with_nulls(tmp_path):
|
193 | 169 | assert data_stats["min_value"] == 1
|
194 | 170 | assert data_stats["max_value"] == 6
|
195 | 171 | assert data_stats["null_count"] == 4
|
196 |
| - |
197 |
| - |
198 |
| -def test_row_group_stats(small_sky_dir): |
199 |
| - partition_info_file = paths.get_parquet_metadata_pointer(small_sky_dir) |
200 |
| - first_row_group = next(read_row_group_fragments(partition_info_file)) |
201 |
| - |
202 |
| - assert row_group_stat_single_value(first_row_group, "Norder") == 0 |
203 |
| - assert row_group_stat_single_value(first_row_group, "Npix") == 11 |
204 |
| - |
205 |
| - with pytest.raises(ValueError, match="doesn't have expected key"): |
206 |
| - row_group_stat_single_value(first_row_group, "NOT HERE") |
207 |
| - |
208 |
| - with pytest.raises(ValueError, match="stat min != max"): |
209 |
| - row_group_stat_single_value(first_row_group, "ra") |
210 |
| - |
211 |
| - |
212 |
| -# def test_get_healpix_pixel_from_metadata(small_sky_dir): |
213 |
| -# partition_info_file = paths.get_parquet_metadata_pointer(small_sky_dir) |
214 |
| -# single_metadata = file_io.read_parquet_metadata(partition_info_file) |
215 |
| -# pixel = get_healpix_pixel_from_metadata(single_metadata) |
216 |
| -# assert pixel == HealpixPixel(0, 11) |
217 |
| - |
218 |
| - |
219 |
| -# def test_get_healpix_pixel_from_metadata_min_max(tmp_path): |
220 |
| -# good_healpix_dataframe = pd.DataFrame({"data": [0, 1], "Norder": [1, 1], "Npix": [44, 44]}) |
221 |
| -# metadata_filename = tmp_path / "non_healpix_metadata.parquet" |
222 |
| -# good_healpix_dataframe.to_parquet(metadata_filename) |
223 |
| -# single_metadata = file_io.read_parquet_metadata(metadata_filename) |
224 |
| -# pixel = get_healpix_pixel_from_metadata(single_metadata) |
225 |
| -# assert pixel == HealpixPixel(1, 44) |
226 |
| - |
227 |
| -# non_healpix_dataframe = pd.DataFrame({"data": [0, 1], "Npix": [45, 44]}) |
228 |
| -# non_healpix_dataframe.to_parquet(metadata_filename) |
229 |
| -# single_metadata = file_io.read_parquet_metadata(metadata_filename) |
230 |
| -# with pytest.raises(ValueError, match="Npix stat min != max"): |
231 |
| -# get_healpix_pixel_from_metadata(single_metadata) |
232 |
| - |
233 |
| -# non_healpix_dataframe = pd.DataFrame({"data": [0, 1], "Norder": [5, 6]}) |
234 |
| -# non_healpix_dataframe.to_parquet(metadata_filename) |
235 |
| -# single_metadata = file_io.read_parquet_metadata(metadata_filename) |
236 |
| -# with pytest.raises(ValueError, match="Norder stat min != max"): |
237 |
| -# get_healpix_pixel_from_metadata(single_metadata) |
238 |
| - |
239 |
| - |
240 |
| -# def test_get_healpix_pixel_from_metadata_fail(tmp_path): |
241 |
| -# empty_dataframe = pd.DataFrame() |
242 |
| -# metadata_filename = tmp_path / "empty_metadata.parquet" |
243 |
| -# empty_dataframe.to_parquet(metadata_filename) |
244 |
| -# single_metadata = file_io.read_parquet_metadata(metadata_filename) |
245 |
| -# with pytest.raises(ValueError, match="empty table"): |
246 |
| -# get_healpix_pixel_from_metadata(single_metadata) |
247 |
| - |
248 |
| -# non_healpix_dataframe = pd.DataFrame({"data": [0], "Npix": [45]}) |
249 |
| -# metadata_filename = tmp_path / "non_healpix_metadata.parquet" |
250 |
| -# non_healpix_dataframe.to_parquet(metadata_filename) |
251 |
| -# single_metadata = file_io.read_parquet_metadata(metadata_filename) |
252 |
| -# with pytest.raises(ValueError, match="missing Norder"): |
253 |
| -# get_healpix_pixel_from_metadata(single_metadata) |
254 |
| - |
255 |
| - |
256 |
| -# def test_get_healpix_pixel_from_metadata_columns(tmp_path): |
257 |
| -# """Test fetching the healpix pixel from columns with non-default names.""" |
258 |
| -# non_healpix_dataframe = pd.DataFrame({"data": [1], "Npix": [45], "join_Norder": [2], "join_Npix": [3]}) |
259 |
| -# metadata_filename = tmp_path / "non_healpix_metadata.parquet" |
260 |
| -# non_healpix_dataframe.to_parquet(metadata_filename) |
261 |
| -# single_metadata = file_io.read_parquet_metadata(metadata_filename) |
262 |
| -# with pytest.raises(ValueError, match="missing Norder"): |
263 |
| -# get_healpix_pixel_from_metadata(single_metadata) |
264 |
| - |
265 |
| -# pixel = get_healpix_pixel_from_metadata(single_metadata, norder_column="data") |
266 |
| -# assert pixel == HealpixPixel(1, 45) |
267 |
| - |
268 |
| -# pixel = get_healpix_pixel_from_metadata( |
269 |
| -# single_metadata, norder_column="join_Norder", npix_column="join_Npix" |
270 |
| -# ) |
271 |
| -# assert pixel == HealpixPixel(2, 3) |
272 |
| - |
273 |
| -# ## People can do silly things! |
274 |
| -# pixel = get_healpix_pixel_from_metadata(single_metadata, norder_column="data", npix_column="join_Npix") |
275 |
| -# assert pixel == HealpixPixel(1, 3) |
0 commit comments