fix(): Handle numpy arrays in Expression.dimensions property
#1735
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.
fix: Handle numpy arrays in Expression.dimensions property
Fixed AssertionError when setting output_units on expressions that evaluate
to plain numpy arrays (e.g., math.exp(solution.CfVec[0])). Changed the
dimensions property to explicitly handle numpy.ndarray types as dimensionless
instead of using assertion.
Added regression test to prevent future issues.
Note
Fixes Expression.dimensions to treat plain numbers and
numpy.ndarrayresults as dimensionless and to raise a clear error for unsupported types. Adds a regression test ensuring math functions returningnumpyarrays (e.g.,math.exp(solution.CfVec[0])) are handled and that settingoutput_unitsremains valid.types.py: adjustExpression.dimensionslogic (dimensionless forNumber/np.ndarray; remove assert; add explicitValueErrorfor unknown types)tests/simulation/test_expressions.py: new testtest_dimensions_with_numpy_array_resultcovering solver variable, math function, plain numbers, andoutput_unitsassignmentWritten by Cursor Bugbot for commit 213095b. This will update automatically on new commits. Configure here.