Repository navigation
feat(schema): T-dependent property curves (#148) - #185
Merged
Merged
Conversation
Adds `<prop>_curve = {temps_K = [...], values = [...]}` TOML support
with linear interpolation for 9 properties: thermal_conductivity,
specific_heat, thermal_expansion, youngs_modulus, yield_strength,
resistivity, refractive_index, light_yield, decay_time.
New module `pymat.curves` defines `TempCurve` (frozen dataclass) with
piecewise-linear interpolation; out-of-range temps CLAMP to nearest knot
(per ADR-0003 §2 — engineering data extrapolated below its measured
range is a lie). Validation at construction: empty/unsorted/mismatched
arrays raise immediately, not at query time.
Properties (src/pymat/properties.py):
- New `<prop>_curve: Optional[TempCurve] = None` sibling fields on the
9 listed properties across Mechanical/Thermal/Electrical/Optical
dataclasses.
- New `<prop>_at(T)` evaluators on each dataclass (8 new + 1 updated).
- Shared `_eval_curve_or_scalar()` helper dispatches: curve > scalar.
- Existing `thermal_conductivity_at(T)` updated to consult curve first;
legacy `_ref_temp + _coeff` linear path kept intact for backwards
compat (precedence: curve > legacy linear > scalar).
Loader (src/pymat/loader.py):
- New `_curve` branch in `update_properties` — when a key ends in
`_curve` and value is a dict, build via `TempCurve.from_toml`. Unknown
curve fields silently ignored (consistent with hasattr-based
assignment on other props).
Tests: tests/test_temp_curves.py (24 tests):
- TempCurve interpolation: exact knot, between knots, clamp below/above,
single-point, empty/unsorted/mismatched at construction
- Loader: curve parsing, curve-without-scalar, invalid raises at load,
unknown-prop curve silently ignored
- Evaluators: curve-first precedence, scalar fallback, legacy
ref_temp+coeff still works
- 8 new `_at(T)` methods parametrized
- Full corpus loads without curves (regression)
Defers `mat.at(T=...)` view to a follow-up PR — issue text only requires
the per-dataclass `_at(T)` methods, and the view adds API surface
without unblocking downstream work.
Full suite: 524 passed, 11 skipped, no regressions.
Closes #148
6 tasks
3 tasks done
gerchowl
added a commit
that referenced
this pull request
May 6, 2026
Bundles four schema-foundation feats merged after 3.9.0 plus the Vis public-API clarification into a single release: - feat(schema): _sources provenance table (#150 / #182) - feat(schema): _stddev sibling sugar + ufloat boundary helper (#149 / #183) - feat(policy): data licensing policy + CI license gate (#174 / #184) - feat(schema): T-dependent property curves (#148 / #185) - fix(vis): declare Vis as public API (#98 / #186) Three feats × one fix → minor version bump per semver. The version 3.9.1 originally proposed for the Vis public-API change alone became inconsistent once the four schema feats had landed on main without their own release cut, so they're rolled into 3.10.0 honestly rather than shipped as a misleading patch. CHANGELOG entry for 3.10.0 covers all five items with PR + issue links. .release-please-manifest.json synced to 3.10.0 so the open release-please PR (#80) recomputes correctly going forward.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
<prop>_curve = {temps_K = [...], values = [...]}TOML support with linear interpolation for 9 properties:thermal_conductivity,specific_heat,thermal_expansion,youngs_modulus,yield_strength,resistivity,refractive_index,light_yield,decay_time.Changes
src/pymat/curves.py(new)TempCurvefrozen dataclass withinterpolate(T), validation at constructionsrc/pymat/properties.py<prop>_curvesibling fields + 8 new<prop>_at(T)methods + 1 updated (thermal_conductivity_at) + shared_eval_curve_or_scalarhelpersrc/pymat/loader.py_curvebranch inupdate_properties— buildsTempCurve.from_toml()when key ends in_curveand value is a dicttests/test_temp_curves.py(new)Edge cases (per ADR-0003 §2 — pinned)
Backwards compatibility
thermal_conductivity_at(T)precedence: curve > legacy_ref_temp + _coefflinear > scalar. The legacy_ref_temp / _coefffields stay; existing TOMLs using them continue to work unchanged (regression test included).*_qtyPint properties and JSON serialization)._curvefields: fully backwards-compatible, full corpus loads (regression test included).Deferred
mat.at(T=...)view (mentioned in ADR-0003 §2) is not in this PR. The issue text only requires "linear interpolation inproperties.py"; the per-dataclass_at(T)methods satisfy that. The view adds API surface without unblocking downstream work — split into a follow-up if/when needed.Test plan
pytest tests/test_temp_curves.py— 24 tests passpytest tests/test_temp_curves.py tests/test_check_licenses.py tests/test_sources.py tests/test_stddev_sugar.py— all 67 foundation tests pass togetherruff checkclean,ruff formatno diffRisks / regressions considered
_curvekeys leaking into_valueparsing path — handled by explicit_curvebranch withcontinuebefore the_valuebranch.<prop>_curvefield-existence check — useshasattr(prop_obj, curve_field)so a curve for a non-existent prop is silently dropped (matches existing assignment semantics; explicit test).numpydependency — implementation uses pure Python (no numpy import). No new transitive deps.value * ureg(unit)exactly as*_qtyproperties do; no new Quantity-shape surprises.frozen=Trueprevents reassignment, but lists inside are still mutable; per-callinterpolate(T)is read-only so this is safe in practice (andfrom_tomldefensively copies vialist(...)).Closes #148
Schema foundation series complete: #150 (merged) → #149 (merged) → #174 (merged) → #148 (this PR).