⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@benflexcompute
Copy link
Collaborator

@benflexcompute benflexcompute commented Jan 16, 2026

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.ndarray results as dimensionless and to raise a clear error for unsupported types. Adds a regression test ensuring math functions returning numpy arrays (e.g., math.exp(solution.CfVec[0])) are handled and that setting output_units remains valid.

  • Update types.py: adjust Expression.dimensions logic (dimensionless for Number/np.ndarray; remove assert; add explicit ValueError for unknown types)
  • Add tests/simulation/test_expressions.py: new test test_dimensions_with_numpy_array_result covering solver variable, math function, plain numbers, and output_units assignment

Written by Cursor Bugbot for commit 213095b. This will update automatically on new commits. Configure here.

@benflexcompute benflexcompute merged commit 88302ea into main Jan 16, 2026
21 checks passed
@benflexcompute benflexcompute deleted the BenY/FixExpression branch January 16, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants