Address holistic review findings; bump to 1.6.4#16
Merged
Merged
Conversation
Documentation
- isinstance_types: teach `Q[Dim, Any]` (a bare `Q[Dim]` means
`Quantity[Dim, Numpy1DArray]` statically, so a TypeIs narrow of a scalar
quantity collapses to Never). Warning box in usage.md, fixed README snippet.
- `Q` is the alias each module creates itself; the library exports no `Q`
(the accidental re-export from encomp.constants is gone).
- Document: the pint application-registry takeover and the pinned registry
options, eager fluid-name resolution, tolerant `<=` / `>=`, that
`plus_minus()` leaves the dimensionality-typed system, and the closed set of
accepted magnitude / unit types.
- Replace the ~80 hardcoded CoolProp fluid-name listings with the
`get_global_param_string` one-liners plus examples.
- Docstrings for the public members that rendered empty in the API reference.
Typing
- New unit literals: `ppm`, `torr`, `J/kg`, `J/g`, `g/cm3` family, and the new
`MassPerNormalVolumeUnits`, `MolarDensityUnits`, `MolarSpecificEnthalpyUnits`,
`PowerPerAreaUnits`, each with matching `__new__` overloads.
- New `__mul__` / `__truediv__` pairs: Force/Area=Pressure, Force*Length=Energy,
Force*Velocity=Power, Mass/MolarMass=Substance, Substance/Volume=MolarDensity,
HeatTransferCoefficient*TemperatureDifference=PowerPerArea,
ThermalConductivity/Length=HeatTransferCoefficient, and their inverses.
- `__getitem__` accepts boolean masks and integer index arrays, so the
`q[q > threshold]` idiom the comparison operators produce type-checks.
- `ideal_gas_density` accepts scalar `T` / `M` alongside a vector `P`.
- New dimensionalities `SurfaceTension` and `MolarSpecificHeatCapacity`; typed
`Fluid.RHOCRIT/CVMASS/CPMOLAR/CVMOLAR/GAS_CONSTANT/I/TAU` and
`HumidAir.CV/CVha` (the latter two now match `C`/`Cha` instead of resolving to
the generic `SpecificHeatCapacity`).
Behavior
- `Quantity(True)` raises: bool is an int subclass and silently became 1.0.
- Passing a `Quantity` as the *unit* raises, statically and at runtime -- its
magnitude was silently dropped. `.to(qty)` still accepts one.
- `Fluid("wat3r", ...)` raises at construction; the name is resolved against
CoolProp once per name (only successful resolutions are cached).
- Writing a pinned registry option logs a warning instead of being discarded in
silence.
- `CoolPropFluid.__getattr__` points at `.search()` for an unknown property.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Patch release addressing every finding of the 1.6.3 holistic review. No breaking API removals; the additions and the three input-tightenings below are the whole change.
Documentation
isinstance_types(x, Q[Dim])mis-narrows under strict typing. A bareQ[Dim]meansQuantity[Dim, Numpy1DArray]to a type checker (theMTdefault), so aTypeIsnarrow of a scalar quantity collapses toNever. The docs now teachQ[Dim, Any], with a warning box inusage.mdand a fixed README snippet.Qis not an importable name. Every module creates the alias itself (from encomp.units import Quantity as Q). The accidental re-export fromencomp.constantsis gone, and a test pins that neitherencomp.unitsnorencomp.constantsexposesQ.<=/>=;plus_minus()returning apint.Measurementoutside the typed system; the closed set of accepted magnitude and unit types.CoolPropFluid.__init__are replaced by theget_global_param_string(...)one-liners plus examples, so they cannot drift from the installed backend.Typing (additive)
ppm,torr,J/kg,J/g, theg/cm3family — plus newMassPerNormalVolumeUnits,MolarDensityUnits,MolarSpecificEnthalpyUnitsandPowerPerAreaUnits, each with matchingQuantity.__new__overloads.__mul__/__truediv__pairs and their inverses:Force / Area = Pressure,Force * Length = Energy,Force * Velocity = Power,Mass / MolarMass = Substance,Substance / Volume = MolarDensity,HeatTransferCoefficient * TemperatureDifference = PowerPerArea,ThermalConductivity / Length = HeatTransferCoefficient. All 27 are verified runtime-sound and inverse-closed bytest_overload_conformance.Quantity.__getitem__accepts boolean masks and integer index arrays, soq[q > threshold]— the exact mask type the comparison operators return — now type-checks.ideal_gas_density(P, T, M)accepts scalarT/Malongside a vectorP.SurfaceTensionandMolarSpecificHeatCapacity, and typed accessorsFluid.RHOCRIT / CVMASS / CPMOLAR / CVMOLAR / GAS_CONSTANT / I / TAU.Behavior changes
Quantity(True)raisesTypeError.boolis anintsubclass, so it silently became1.0dimensionless. Comparisons againstTrue/Falseare unaffected.Quantityas the unit raisesTypeError, statically and at runtime — its magnitude was silently dropped..to(qty), where reusing another quantity's unit is the point, still accepts one.Fluid("wat3r", ...)raisesValueErrorat construction rather than at the first property access. The name is resolved against CoolProp once per(backend, fluids)pair; only successful resolutions are cached, so a transient failure is never remembered as "invalid".HumidAir.CV/CVhareturnSpecificHeatPerDryAir/SpecificHeatPerHumidAir, matchingC/Cha, instead of falling back to the genericSpecificHeatCapacity.force_ndarray,force_ndarray_like,autoconvert_offset_to_baseunit) logs a warning instead of being discarded in silence. The write is still discarded.CoolPropFluid.__getattr__names the class and points at.search()for an unknown property.Findings n6 (
fluid_namevsname), n10 (warnings.warninself_check), n11 (reprvstype) and the pint-registry takeover are settled decisions rather than defects; each is now recorded in a code comment so future reviews don't re-flag them.Note for the release notes: unit spellings that previously inferred
UnknownDimensionalitynow infer their specific dimensionality. That is the helpful direction, but it can surface new type errors in over-annotated user code.Verification
pytest(741 passed),ruff check+ruff format --check,pyright(strict, 0 errors),pyrefly(0 errors), and the ReadTheDocs-parity Sphinx build (-W) all pass locally.tyis not gating, per project convention.🤖 Generated with Claude Code