Add ruff and ty as dev dependencies, fix lint/type findings
ruff removed unused imports across analysis.py and several test files. ty caught a wrong dict[int, int] annotation on StreamingStepsDataset's mat_map (materials are strings) and a real bug in steps_to_parquet.py where --compression none passed None to polars' write_parquet, which only accepts the literal "uncompressed". Also narrows a few Optional-typed attributes (ddpm_schedule, Normalizer.mean/std) with asserts and aligns __getitem__'s parameter name with torch's Dataset base class. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,11 +9,14 @@ Usage:
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
from typing import Literal
|
||||
|
||||
import awkward as ak
|
||||
import polars as pl
|
||||
import uproot
|
||||
|
||||
ParquetCompression = Literal["lz4", "uncompressed", "snappy", "gzip", "brotli", "zstd"]
|
||||
|
||||
|
||||
def _batch_to_polars(batch: ak.Array) -> pl.DataFrame:
|
||||
"""Convert one awkward-array batch to a Polars DataFrame.
|
||||
@@ -37,7 +40,7 @@ def convert_steps_to_parquet(
|
||||
output_path: str | Path | None = None,
|
||||
batch_size: str = "100 MB",
|
||||
tree_name: str = "Steps",
|
||||
compression: str = "snappy",
|
||||
compression: ParquetCompression = "snappy",
|
||||
) -> Path:
|
||||
"""Read *tree_name* from *root_path* and write it to a Parquet file.
|
||||
|
||||
@@ -108,7 +111,7 @@ def main() -> None:
|
||||
output_path=args.output,
|
||||
batch_size=args.batch_size,
|
||||
tree_name=args.tree,
|
||||
compression=None if args.compression == "none" else args.compression,
|
||||
compression="uncompressed" if args.compression == "none" else args.compression,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user