Tensor Hierarchy Reference
Complete data dictionary for all tensor types, protocols, default implementations, and validation rules introduced in Feature 025.
For architectural context, see Tensor Hierarchy Architecture. For theory behind the math, see Input-Output Economics and the Leontief Inverse, The Imperial Rent Field: Spatial Value Extraction, and Class Mobility: Markov Chains and Stationary Distributions.
Level 1 Tensor Types
InterIndustryFlow
- class InterIndustryFlow
BEA input-output direct requirements coefficient matrix. Level 1 tensor sourced from
fact_bea_io_coefficient.Field
Type
Description
yearintBEA data year. Constraint: ≥ 1997.
table_typeIOTableTypeWhich BEA table this was derived from. Default:
USE.industrieslist[str]Ordered list of BEA Summary-level industry codes (~70 items).
coefficientsnp.ndarrayDirect requirements matrix A, shape
(n, n),float64.Computed property:
n_industries→int: Number of industries (length ofindustries).
Constraints:
coefficients.shape == (n, n)wheren = len(industries).Source:
DefaultInterIndustryFlowSourcereads fromfact_bea_io_coefficientpopulated byBEAIOLoader.
IOTableType
- class IOTableType
Enum for BEA I-O table classification.
Value
Description
USEUse table (commodity-by-industry intermediate use). Basis for direct requirements coefficients A[i,j]. This is the primary source.
MAKEMake table (industry-by-commodity output structure).
SUPPLYSupply table (total supply of commodities from all sources).
TOTAL_REQTotal requirements (Leontief inverse as published by BEA).
VisibilityMetric
- class VisibilityMetric
Diagonal visibility tensor for the four Marxian departments. Wraps Feature 015 gamma module output into the tensor hierarchy.
Field
Type
Description
yearintData year. Constraint: ≥ 2003 (ATUS availability).
g_diagonalnp.ndarrayVisibility diagonal
[g_11, g_22a, g_22b, g_33], shape(4,).g_11floatDepartment I visibility. Range: [0.0, 1.0]. Expected: ≈ 0.97.
g_22afloatDepartment IIa visibility. Range: [0.0, 1.0]. Expected: ≈ 0.97.
g_22bfloatDepartment IIb visibility. Range: [0.0, 1.0]. Expected: ≈ 0.97.
g_33floatDepartment III visibility (care work). Range: [0.0, 1.0]. Expected: [0.20, 0.40]. Approximately 1/3 of US care work is commodified (ATUS data).
is_estimatedboolTrueif values are estimated/MVP rather than computed from ATUS. Default:False.Source:
DefaultVisibilitySourcewrapsDefaultGammaIIICalculator.
GeographicFlow
- class GeographicFlow
BTS FAF origin-destination commodity flow matrix. Level 1 tensor sourced from
fact_faf_commodity_flow.Field
Type
Description
yearintFAF data year. Constraint: ≥ 2012 (FAF5 data begins).
areaslist[str]Ordered list of CFS Area codes (~130 areas).
flow_matrixnp.ndarrayO-D flow matrix, shape
(n, n), values in millions USD.commodity_codestr | NoneSCTG 2-digit code for commodity-specific flow;
Nonefor all-commodity aggregate. Default:None.Computed property:
n_areas→int: Number of CFS areas (length ofareas).
Constraints:
flow_matrix.shape == (n, n)wheren = len(areas).Source:
DefaultGeographicFlowSourcereads fromfact_faf_commodity_flowpopulated byFAFLoader.
ReproductionRequirements
- class ReproductionRequirements
Consumption and reproductive labor requirements by social class. Level 1 tensor combining CEX consumer expenditure and ATUS time-use data.
Field
Type
Description
yearintData year. Constraint: ≥ 2000.
consumptiondictNested dict:
class → department → use_value_category → hours. Represents use-value bundles consumed per class per Marxian department.reproductive_labordictNested dict:
reproduced_class → laborer_class → type → hours. Represents labor performed to reproduce each class.Note
Production loader deferred (US4).
DefaultReproductionSourcereturnsNoDataSentinelfor all queries. All tests use synthetic data.Source:
DefaultReproductionSource(stub).
ClassTransitionMatrix
- class ClassTransitionMatrix
Stochastic matrix of class mobility probabilities. Level 1 tensor from PSID panel study data.
Field
Type
Description
periodtuple[int, int](start_year, end_year)defining the transition window.classeslist[str]Ordered list of
SocialRoleclass names.transition_matrixnp.ndarrayRow-stochastic matrix, shape
(n, n). Each row sums to 1.0 (tolerance 1e-6). P[i,j] = probability of class i → class j.Computed property:
n_classes→int: Number of classes (length ofclasses).
Constraints: Shape
(n, n),n = len(classes). Row sums = 1.0 ± 1e-6.Note
Production loader deferred (US5).
DefaultClassTransitionSourcereturnsNoDataSentinel. Computation engine (DefaultClassTransitionComputer) is fully implemented.Source:
DefaultClassTransitionSource(stub).
Level 2 Tensor Types
LeontiefInverse
- class LeontiefInverse
Total requirements matrix L = (I − A)⁻¹. Level 2 tensor derived from
InterIndustryFlow.Field
Type
Description
yearintSame as source
InterIndustryFlowyear. Constraint: ≥ 1997.industrieslist[str]Same ordered BEA industry codes as source
InterIndustryFlow.inverse_matrixnp.ndarrayTotal requirements matrix (I − A)⁻¹, shape
(n, n). All elements ≥ 0. Diagonal ≥ 1.0.Computed property:
n_industries→int: Number of industries.
Mathematical guarantee: If Hawkins-Simon holds (all column sums of A < 1), then: all
inverse_matrixelements ≥ 0, all diagonal elements ≥ 1.0.Computed by:
DefaultLeontiefComputer.
ImperialRentField
- class ImperialRentField
Net value extraction (inflow − outflow) per CFS area. Level 2 tensor derived from
GeographicFlow.Field
Type
Description
yearintSame as source
GeographicFlowyear. Constraint: ≥ 2012.areaslist[str]Same ordered CFS Area codes as source
GeographicFlow.phinp.ndarrayNet value extraction per area, shape
(n_areas,), signed, millions USD. Positive = core (net importer). Negative = periphery (net exporter). Conservation: |Σφ| < 0.01% of total flow.Computed property:
n_areas→int: Number of CFS areas.
Computed by:
DefaultImperialRentComputer.
ShadowSubsidyTensor
- class ShadowSubsidyTensor
Shadow subsidy from un-commodified reproductive labor. Level 2 tensor derived from
VisibilityMetric.Field
Type
Description
yearintReference year. Constraint: ≥ 2000.
phi_iii_labor_hoursfloatShadow subsidy in labor-hours: Dept III value × (1 − g₃₃). ≥ 0.
phi_iii_dollarsfloat | NoneDollar value if MELT (Monetary Expression of Labor Time) is available, else
None.melt_availableboolWhether MELT was used for the dollar conversion. Default:
False.Computed by:
DefaultVisibilitySource.
StationaryDistribution
- class StationaryDistribution
Long-run class distribution from ClassTransitionMatrix eigenvector. Level 2 tensor derived from
ClassTransitionMatrix.Field
Type
Description
periodtuple[int, int]Same
(start_year, end_year)as sourceClassTransitionMatrix.classeslist[str]Same ordered class names as source
ClassTransitionMatrix.distributionnp.ndarrayStationary distribution π, shape
(n_classes,). All elements ≥ 0. Sum = 1.0 (tolerance 1e-6). Satisfies π @ P = π.Computed property:
n_classes→int: Number of classes.
Computed by:
DefaultClassTransitionComputer.
Source Protocols
Protocol |
Methods |
Returns |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Computation Protocols
Protocol |
Methods |
Returns |
|---|---|---|
|
|
|
|
|
|
|
|
|
All protocols use @runtime_checkable, enabling isinstance checks at
runtime.
Default Implementations
Protocol |
Default Class |
Module |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Additional helper classes:
DefaultGeographicAggregator— Aggregates CFS area flows to state level.DefaultClassTransitionComputer— Computes stationary distributions and class aggregation (not a protocol implementation, a standalone computer).DefaultReproductionRequirementsComputer— Computes reproduction requirements from synthetic data (not a protocol implementation).
All implementations are in src/babylon/economics/tensor_hierarchy/.
Validation Rules
Rule |
Expected |
Warning |
Fail |
Function |
|---|---|---|---|---|
I-O col sum max |
≤ 0.90 |
> 0.90 |
≥ 1.0 |
|
Individual coefficient |
≤ 0.60 |
> 0.60 |
< 0 or ≥ 1.0 |
(inline) |
Leontief elements |
≥ 0 |
— |
< −1e-10 |
|
Leontief diagonal |
≥ 1.0 |
— |
< 1.0 − 1e-10 |
|
g_33 (Dept III) |
[0.20, 0.40] |
[0.10, 0.50] |
<0 or >1 |
|
g_11, g_22a, g_22b |
[0.90, 1.0] |
[0.70, 1.0] |
<0 or >1 |
|
Rent conservation |
|Σφ|/total < 0.01% |
|Σφ|/total < 0.1% |
|Σφ|/total ≥ 1% |
|
Transition row sum |
deviation ≤ 1e-6 |
deviation ≤ 1e-4 |
deviation > 1e-4 |
|
Transition diagonal |
≥ 0.50 |
≥ 0.20 |
< 0 |
|
All validation functions return (bool, str | None):
(True, None) = pass, (True, str) = warning, (False, str) = fail.