Repository navigation
Conversation
Code Review (by AI)Bugs / CorrectnessSilent zero-fill for missing 3D time periods ( # current
arrs_ = [(i if i is not None else np.zeros_like(prototype)) for i in arrs]
# suggested
fill = np.full_like(prototype, np.nan) if np.issubdtype(prototype.dtype, np.floating) else np.zeros_like(prototype)
arrs_ = [(i if i is not None else fill) for i in arrs]
if isinstance(column, pa.ChunkedArray):
return column.to_numpy(zero_copy_only=False) # not .to_numpy()Empty PerformanceOne for k in data_names:
content = _parquet_column_to_numpy(pf.read(columns=[k]), k)For files with many columns (common for full skim tables) this causes N extra seeks/reads. A single Minor
What's good
|
|
superceded |
Skim (multi-dimension) data currently must be read from OMX or ZARR, or from a multi-indexed dataframe via xarray, which is slow. Parquet storage is substantially smaller and faster to read, so this adds a dedicated parquet reader for multi-dimension data.
Input files have two index columns (
otaz,dtazby default) plus one column per matrix table, named exactly as in OMX including__time period suffixes, which are assembled into the third dimension.Changes
sharrow/dataset.pyfrom_parquet_3d(...): accepts one path or an iterable of paths; mirrors thefrom_omx_3dsignature (index_names,time_periods,time_period_sep,max_float_precision,ignore) and its handling of 2D vars, missing time period pages (zero-filled), and float downcasting._parquet_layout(...): inspects the index columns of each file and classifies the layout asrow-major,column-major,unsorted-dense, orsparse. Dense detection is by first-occurrence unique labels; when neither dense ordering matches, uniqueness of index pairs is checked to distinguish a genuinely dense-but-misordered file from a coincidental row count.set_index(...).to_xarray(); dense-but-unsorted raisesValueErrorrather than silently taking the slow path.sharrow/tests/test_datasets.py: coverage for row-major, column-major, sparse with gaps and shuffling, dense-but-unsorted error, multiple files with mixed layouts, mismatched index ordering across files, andignorefiltering.docs/api.rst: lists the new constructor.Notes for review
from_omx_3d, the returned dataset is numpy-backed rather than dask-backed; the parquet read is eager.ParquetFile, matching how the OMX reader takes discrete files.