Repository navigation
[0.2.0] - 2026-11-03
Breaking
- Dropped Python 3.9 and 3.10 support; now requires Python ≥3.11 (tested through 3.14). Python 3.10 is end-of-life and missing important security fixes.
read()gives a(polars.DataFrame, metadata)tuple, replacing the old pandasread(...) -> pandas.DataFrame.- New
scan()gives a(polars.LazyFrame, metadata)tuple. load()removed, useread()orscan()for all files (BDF or non-BDF).read/scansignature changed:source→pathregistry_pathremoved.include_optionalremoved — optional BDF columns are now always kept.extra_columns(extra column mapping dict) removedinclude_unknownadded, keeps all non-spec columns in the dataframe under their original names (defaultFalse).tzkwarg added for naive datetimes.
parse()is removed — useread(path, normalize=False, validate=False).save()rewritten on Polars with more files supported, avalidatekwarg, and alabelsoption ("preferred" | "machine" | "unchanged") replacing the oldhuman=True/Falsetoggle.save()to JSON previously output NDJSON, which cannot be read by standard JSON parsers. These are now two distinct options, save to ".ndjson" to get newline-delimited JSON.- Top-level
plugins()function removed; usebdf.plugins.list_sources()instead. ingest()gets the same kwarg changes asread/scan/save:include_optionalremoved,include_unknownadded, andhuman: bool = False→labels: Literal["preferred", "machine", "unchanged"] = "machine".ingestCLI:--include-optionalremoved,--include-unknownadded,--labelsoption added.- CLI:
cleanandplotno longer take--assume-bdf. - Column spec is now ontology-driven (
bdf.spec.ColumnOntology, synced from the published BDF ontology release);bdf.normalize,bdf.units,bdf.detect, andbdf.data_sourcesare removed in favor ofbdf.plugins,bdf.table_parsers,bdf.metadata_parsers, andbdf.table_normalizers. fastndainstall extra renamed tonda.- Module paths
bdf.validate,bdf.templates, andbdf.ingestrenamed to private submodules; thevalidate(),templates(), andingest()functions are unchanged and remain importable from thebdfnamespace. Fixes module/function name collisions. Quantity.unit_conversionrenamed toconvert_to.- Arbin normalizers (csv, xlsx) map Charge/Discharge Capacity and Energy to the
schedule_*columns (Schedule Charging Capacity / Ah, ...) from ontology 1.3.0, reflecting the operator-defined reset behavior Arbin confirmed; these columns previously landed on the never-resetting test-scoped terms. read()/scan()raiseBDFValidationErrorwhen an elapsed-time column's increments disagree with the recorded timestamps (e.g. milliseconds stored under a seconds header); passreconcile_time=Trueto repair known unit factors orvalidate=Falseto load the data as-is.bdf.readandbdf.scanreturn a typedMetadatamodel as the second tuple element, replacing the plaindict. Read a field by attribute (e.g.metadata.bdf.source,metadata.battinfo_test.test.started_at) rather than by key.bdf.savetakes a typedMetadatamodel inmetadata=, replacing the plaindict. PassMetadata(...), the modelbdf.readreturns, orMetadata.model_validate(mapping)for a mapping an earlier version wrote.
Added
- BDF parsers/normalizers for BDF JSON, NDJSON, Arrow/Feather (IPC), XLSX.
- Arbin MITS XLSX parser.
- Arbin
.resparser (Access/MDB, via pyodbc on Windows or MDB Tools elsewhere;arbin_resextra). Contributed by @Abbta. - BioLogic
.mprbinary parser via yadg (mprextra), including the EIS quantities; adds areverse_signoption to normalizer synonyms. - PyBaMM simulation-output table normalizer (
pybammplugin). validatenow checks ontology-defined derived-column consistency.- Time-scale detection (GH #65): elapsed-time columns are cross-checked against wall-clock increments on read, following the fsck model (detect loudly by default, repair only with the explicit
reconcile_time=Trueflag; repairs are recorded undermetadata["time_reconciliation"]).validatereports the same mismatch as atime_scalefinding. - Ontology 1.3.0:
schedule_*capacity/energy terms for schedule-driven accumulators andstep_record_index(replacing the deprecatedstep_index). - Ontology release pinning with a bundled snapshot,
BDF_CACHE_DIRcache override, and a daily auto-sync workflow. - New optional extras
excel,mat,mpr,yamlfor additional file formats, and anallbundle covering all user-facing feature extras. save()streams aLazyFramestraight to disk via the polarssink_*writers (csv, parquet, ipc, ndjson), so a scanned table no longer has to fit in memory to be written; json and xlsx still collect.- CLI piping:
convertandvalidateaccept-to read from stdin, andconvert --to -writes BDF CSV to stdout; status messages go to stderr. Exit codes: 0 valid, 1 invalid, 2 unreadable. - Docs: example notebooks now execute live via myst-nb, plus a generated "Supported Plugins" reference page.
read()andscan()restore the.metadata.jsonsidecar a priorsave()wrote, in place of the plugin parser's metadata.day_month_orderkeyword-only override onbdf.read,bdf.scan,bdf.normalize,TableParser.read, andTableNormalizer.normalize, for a vendor datetime format that leaves a numeric day and month ambiguous."day_first"reads such a date day then month,"month_first"reads it month then day, and the defaultNoneleaves every declared format exactly as the plugin states it. A year-first format (e.g.%Y-%m-%d) or a month-name format (e.g.%d-%b-%y) is never affected.- Every sidecar
save()writes is stamped with its writer's identity undermetadata.bdf(GH #106):bdf_version(the batterydf package),ontology_version(the pinned BDF ontology release), andbattinfo_ref(the upstream commit of the bundled BattINFO schemas). The stamps overwrite on each save, so they always name the file's writer; an emptyMetadatastill writes no sidecar. Metadatagains a sixth record,battinfo_dataset(bdf.BattinfoDataset), mirroring BattINFO's dataset schema: distributions (raw and processed files with checksums and formats), identifiers, and links to the cell and test that produced the data. Nothing fills it automatically yet; it is the documented place for file-level provenance (GH #92, #105). Like the other records it mirrors a pre-1.0 upstream schema and may evolve with it.- Network test that fails when the bundled BattINFO schemas differ from upstream
main; the pinned-commit test could not catch a stale bundle, because a refetch at a commit reproduces it however far upstream moves. The comparison reads the parsed content of the eight managed schema files, so an upstream commit that reformats one of them or that leavesassets/schemas/alone keeps it green.scripts/update_battinfo.py --checkreports the same comparison and exits non-zero when the bundle is stale, and the script now resolves a branch or tag to a commit before it stampsVERSION.
Changed
- I/O layer rebuilt on Polars.
repairandvalidaterebuilt on Polars:fix_time,clean, andvalidate_dfaccept polars (eager or lazy) or pandas frames and return matching kinds, with identical results across input types; the CLI no longer round-trips through pandas.- Dev and docs dependencies moved to PEP 735 dependency-groups; plotting deps moved into a new
plotextra. save()now validates viaColumnOntology.validate_df, which also warns on non-canonical BDF units.ColumnOntology.load_version()now fetches and caches an uncached ontology release instead of raising.NDAParserrenamed toNdaParser; its magic-byte check now recognizes the.ndaxzip container.- Package import is lazy:
import bdfcompletes in ~0.15 s without loading pandas/polars/scipy; heavy dependencies import on first use, making CLI startup near-instant. save()names the metadata sidecar by replacing the final extension (x.bdf.parquet->x.bdf.metadata.json) instead of appending to the full filename.- Reference-data manifest hardening:
datasets.jsonsha256s now hash the stored artifact bytes on every platform (.gitattributespins the artifacts-text; ten entries previously hashed a Windows CRLF rendering and failed to verify on Linux), a CI test now enforces manifest/file agreement, the manifest gainsmanifest_versionand records the canonical artifact record's DOI (10.5281/zenodo.22230066, publishes with the tag), and the Stanford unconverted-file reason is corrected. - A reserved sidecar that fails validation now raises
BDFMetadataError(previously a raw pydanticValidationError); where the document claims a newerbdf_versionthan the installed package, the message says which version wrote it and to upgrade (GH #106). - A metadata sidecar that exists and cannot be restored now raises the new
BDFMetadataErrorinstead of reading as an emptyMetadata: a document that does not decode as UTF-8, one that does not parse as JSON, and one holding a JSON value other than an object. This applies to the reserved.metadata.jsonsidecar and to a plugin-declared sidecar alike. An emptyMetadatanow states that no sidecar exists, so the documentedread()thensave()round trip can no longer write a degraded object over a sidecar the read failed on. The naive-timestampUserWarningis unchanged. save()no longer carries a metadata sidecar from one save to the next. Asave()that states nometadata=beside an existing.metadata.jsonsidecar raisesFileExistsError, because the sidecar describes the data the previous save wrote; passmetadata=to keep or update it,metadata=Metadata()to clear it, or save to a different path. An emptyMetadatanow deletes the sidecar, so a sidecar exists exactly where the artifact has metadata.read()andscan()now cut a preamble metadata source where the table begins, sorawcarries the preamble alone, with neither the header row nor a data row. A caller who drives a metadata parser directly (bypassingread/scan) states no boundary and keeps the whole decoded head, as before. Where the table parser cannot locate the header row, the boundary is unknown andrawkeeps the whole decoded head.rawisNonewhere a file's header row is its first line.
Fixed
arbin_resextra is now part of theallbundle, and its mdbtools backend supports Python 3.10 (polars-access-mdbtools 0.1.3).- Unix-time conversion is now datetime-resolution-safe: previously assumed nanosecond storage and returned values 1000x too small on pandas builds that yield
[us]/[s]/[ms]datetimes. ingestnow lowercases the cell id in per-cell metadata directory paths, stable on case-sensitive filesystems.- Compound file extensions (e.g.
.bdf.csv.gz) no longer fail to match a plugin. - Daylight-saving-time handling in naive-datetime parsing.
- Special characters can be used in units.
ohmanddegCare accepted as units.- Deprecated-column redirection (read/load/save) now follows the ontology's
isReplacedBylink, fixing silent data loss/mislabeling for renamed legacy columns (e.g.step_capacity_ah→step_cumulative_capacity_ah). - Excel parser raises on ambiguous
sheet_patternmatches instead of silently reading only the first matching sheet. - BDF table normalizer now accepts machine-notation and deprecated on-disk headers, fixing read/validate round-trips of default
save()artifacts. validate()now uses plugin detection to decide whether a file is a BDF artifact..jsonartifacts are now valid standalone JSON (a records array viawrite_json); previouslysave()wrote JSON-Lines under the.jsonextension, producing files that failed to parse as JSON outside pandas. Use the new.ndjsonformat for JSON-Lines output.
Install
pip install batterydf # core
pip install "batterydf[all]" # every vendor format and plotting backendRequires Python 3.11 or newer.
The canonical reference artifacts for this release are published at 10.5281/zenodo.22230066.