Backfill unit catalog + constants domains from main; fix Fahrenheit and Generic constants#90
Merged
Conversation
T.CreateChecked(PreciseNumber) throws NotSupportedException for every constant (PreciseNumber's TryConvertToChecked is unimplemented), so the whole PhysicalConstants.Generic surface was unusable. PreciseNumber's supported materialisation path is To<T>(). https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
Restores the units and physical constants that the vectors rework had not yet carried over from main: - ~60 units across 30 dimensions: imperial/US customary (acre, US/imperial gallons, PSI-family pressure via Torr, pound-force, BTU, knot, stone...), CGS (dyne, erg, poise-family, dyn/cm), traditional radiological (curie, rad, rem, roentgen), SI-prefixed conveniences (kPa, kW, MW, kHz, MHz, mA, kV, kΩ, μF/nF/pF, kmol/mmol...), chemistry (millimolar, micromolar, dalton, enzyme unit, cal/mol), and angle/ratio units (gradian, revolution, milliradian, ppm, ppb, % w/w). - Constants for the Acoustics (reference sound pressure/intensity/power, Sabine), Optics (luminous efficacy), NuclearPhysics (atomic mass unit, nuclear magneton) and FluidMechanics (standard air density, water surface tension) domains. - Fixes the inverted Fahrenheit→Kelvin affine conversion: the metadata carried the K→F transform (×1.8, −459.67), so FromFahrenheit(32°F) produced −402 K and threw on the non-negativity guard. Now ×5/9, +255.372; Rankine added on the same scale. Deliberately not ported: Luminance units (no Luminance dimension yet), PerSecond (no RateConstant dimension yet), MolesPerSecond (mislabelled on main — ReactionRate is volumetric), and main's Mathematical constant helpers (generated code uses literals). Dalton is defined as 1 g/mol on MolarMass rather than main's 1.66e-27 (which was the per-particle mass, not a molar mass). https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
|
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
First step of the parity plan: backfills the unit catalog and physical-constant domains that the vectors rework hadn't yet carried over from main, and fixes two real bugs found along the way.
Units (~60 across 30 dimensions)
Each unit gets a named conversion factor in
conversions.json(exact values where defined), an explicit pluralfactoryName, andavailableUnitswiring —From{Unit}factories and typedIn(unit)support come out of the generator.Constants
New domain constants in
domains.json: Acoustics (reference sound pressure/intensity/power, Sabine constant), Optics (luminous efficacy), NuclearPhysics (atomic mass unit, nuclear magneton), FluidMechanics (standard air density, water surface tension).Bug fixes
Temperature.FromFahrenheit(32)computed −402 K and threw on the V0 non-negativity guard. Now ×5/9 +255.372 (exact). Nothing had tested it.PhysicalConstants.Generic.*<T>()was entirely unusable:T.CreateChecked(PreciseNumber)throwsNotSupportedException(PreciseNumber'sTryConvertToCheckedis unimplemented). The generator now emitsPreciseNumber.To<T>(), the supported materialisation path. Also previously untested.Deliberately not ported (with rationale)
PerSecond— no RateConstant dimension yet; same phase.MolesPerSecond— mislabelled on main (ReactionRate is volumetric, mol/(m³·s)).Mathematicalconstant helpers (OneHalf, FourThirds…) — generated code uses literals.Testing
UnitBackfillTestscovering factories across all the new unit families,In(unit)round-trips, the Fahrenheit/Rankine fix, and the new constants.https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
Generated by Claude Code