fix(INCOMP): throw a clean error for molar properties (#1908)#2854
Merged
Conversation
PropsSI('Dmolar','T',298.15,'P',101325,'INCOMP::AEG[0.1]') returned
-infinity and the Python wrapper surfaced the unhelpful "PropsSI
failed ungracefully" because the underlying call set no errstring.
Root cause: IncompressibleBackend never overrode calc_rhomolar (or
the other molar getters), so they fell through to AbstractState's
default that returns the cached _rhomolar member, which clear()
initializes to -_HUGE. The call returned -inf cleanly and the
"failed ungracefully" path was reached because no exception was
thrown to populate errstring.
Override calc_molar_mass / calc_rhomolar / calc_hmolar / calc_smolar /
calc_umolar / calc_cpmolar / calc_cvmolar in IncompressibleBackend to
throw a NotImplementedError naming the mass-basis equivalent. PropsSI
catches the exception and propagates a useful errstring.
Add a Catch2 regression test that the original repro now produces a
non-finite return value AND a non-empty errstring containing
"INCOMP", and that the corresponding mass-basis call still works.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4b6f4e2 to
c445679
Compare
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
Fixes #1908.
The reproducer:
raised the unhelpful "ungracefully" message from the Python wrapper because the underlying
_PropsSIcall returned-infcleanly and set no errstring.Root cause
IncompressibleBackendnever overrodecalc_rhomolar(or the other molar getters), so they fell through toAbstractState's default that returns the cached_rhomolarmember, whichclear()initialises to-_HUGE. The call returned-infcleanly and the "failed ungracefully" path was reached because no exception was thrown.Fix
Override the molar getters in
IncompressibleBackendto throwNotImplementedErrornaming the mass-basis equivalent (Dmass,Hmass, etc.).PropsSIcatches the exception and propagates a usefulerrstring.Test plan
[1908]Catch2 regression test: original repro now returns a non-finite value AND a non-empty errstring containing "INCOMP"; correspondingDmasscall still works[PropsSI]tests pass🤖 Generated with Claude Code