MARIO v1.1.1
This bugfix release rebuilds the GTAP Power MRIO parser around a record-based
assembly engine shared by the CSV and GDX backends, fixing crashes and silent
data losses on recent GTAP exports, and adds an opt-in structured row layout
for the GTAP factor and satellite blocks.
GTAP parser rewrite
- The parser now maps every record onto integer axis positions and accumulates
values directly into dense blocks, so the build cost scales with the number
of records instead of the size of the cartesian label space. A full GTAP
2023 Power MRIO CSV bundle (~7 GB, ~140M records) parses end-to-end in
about 80–90 seconds, where the previous implementation ran for 20+ minutes
before failing. - CSV reading prefers the multithreaded pyarrow engine (with a silent
fallback to the default engine) and logs per-file and per-block progress.
Fixes
- Duplicated record keys no longer crash the CSV path. Recent GTAP CSV
exports flatten several GDX symbols into one file (e.g. combustion and
non-combustion emissions), so the same key can legitimately appear more than
once: duplicated keys are now summed instead of raising
ValueError: cannot handle a non-unique multi-index. - Output- and value-added-based emission accounts are captured. The CSV
export encodes them with theSRC="TOT"placeholder; they were silently
dropped — about one third of the emission record mass in the GTAP 2023
bundle — and now land in the domestic satellite rows of the destination
region (e.g.EMI_CH4_dms_QO), mirroring how the GDX bundles store them. - No more spurious
EMI_0_*satellite rows produced by the fill step of
the previous CSV implementation (which also raised aTypeErroron the
pandas 3 string dtype). EandEYexpose one dense, aligned satellite row set on both
backends, instead of the data-dependent asymmetric row sets of the previous
CSV path.- Any satellite record mass the parser cannot attribute is now reported with a
parser warning instead of being silently dropped.
New: optional structured row layouts for GTAP
-
parse_gtapgained an opt-inmatrix_layoutsargument:db = mario.parse_gtap( path="path/to/bundle", input_format="auto", matrix_layouts={"V": ("Region", "Sector"), "E": ("Region", "Sector")}, )
Factor and satellite rows are exposed as a semantic
(Region, Sector, item)MultiIndex instead of the historical flat string
names (MTAX_AUS_GRObecomes("AUS", "GRO", "MTAX")), and the matching
block specifications are registered on the database. Values are identical to
the flat parse — only the index representation changes. -
Row families without a region or sector of their own (PTAX, VAAD/VTAX
endowments, ETAX, DTAX/ITAX, domestic satellite accounts) carry the
"TOTAL"sentinel on the levels that do not apply. The sentinel is not
part of the Region/Sector sets and passes through aggregation untouched, so
no extra entry is needed in aggregation mapping files. -
The default (
matrix_layouts=None) keeps the historical flat rows, so
existing workflows are unaffected.
Notes
- The GDX backend requires the GAMS Python API; the pip package
gamsapi[transfer]is sufficient to read GDX bundles. - GTAP databases parsed with earlier MARIO versions differ from v1.1.1 output
by design: the emission block now includes the previously dropped output-
and value-added-based accounts, and E/EY share one aligned row set.
Compatibility
- Requires Python 3.11–3.13.
- No API breaking changes since v1.1.0; the
matrix_layoutsargument is
additive and off by default.
Full changelog: v1.1.0...v1.1.1