Repository navigation
Conversation
Widens the temperature-type dispatch to accept np.floating scalars and plain Python int, not just Python float, so values like arr[0] from a float32/float64 array no longer raise a spurious ValueError. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Author
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
Mixture.calc_property'stemperatureargument dispatch only recognized Pythonfloatas a scalar temperature. NumPy floating scalars (e.g.np.float32, which does not subclassfloat) fell through to the method'selsebranch and raised a spuriousValueError, even though such a value arises naturally from indexing into a float array (arr[0]). Plain Pythonintwas rejected for the same reason.Changes
source/bind/python/CEA.pyx: both scalar-dispatch checks inMixture.calc_property(the pressure-dependent and pressure-independent branches) widened fromisinstance(temperature, float)toisinstance(temperature, (float, int, np.floating)). Plain NumPy integer scalars (np.int64, etc.) remain deliberately rejected.source/bind/python/tests/test_mixture.py: 5 new tests covering the dispatch boundary — numpy scalar (float32/float64) accepted and matching thefloatresult, plain Pythonintaccepted and matching thefloatresult, numpy integer scalar still rejected, and an invalid type (string) still rejected.Testing
make py-rebuildpytest source/bind/python/tests -v— 118 passednp.float32scalar temperature); confirms it now returns a result instead of raisingValueErrorCompatibility / Numerical behavior
Only the type-dispatch logic changed — no change to what value is ultimately passed into the Fortran solver for any input that was already accepted.
Drafted with Claude's assistance
isinstance(np.float32(3.0), float)isFalsewhileisinstance(np.float64(3.0), float)isTrueon this platform, explaining why only some numpy scalar dtypes triggered it) before writing the fix.make py-rebuild) against this branch'supstream/mainbase and confirmed all 118 tests pass, including the 5 new ones added for this fix.🤖 Generated with Claude Code