Skip to content

Commit

Permalink
fix: add check that dimension matrix size matches result matrix size
Browse files Browse the repository at this point in the history
No known issue where this happens but this will catch catch implementation flaws with matrix functions
  • Loading branch information
mgreminger committed Oct 20, 2024
1 parent ee05d55 commit 29ffe31
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion public/dimensional_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,12 @@ def evaluate_statements(statements: list[InputAndSystemStatement],

elif is_matrix(evaluated_expression) and (dimensional_analysis_expression is None or \
is_matrix(dimensional_analysis_expression)) and isinstance(symbolic_expression, list) :

if dimensional_analysis_expression is not None and (
evaluated_expression.rows != dimensional_analysis_expression.rows and
evaluated_expression.cols != dimensional_analysis_expression.cols ):
Exception("Internal Error: Dimension matrix size does not match result matrix size. Report error to [email protected]")

matrix_results = []
for i in range(evaluated_expression.rows):
current_row = []
Expand All @@ -2786,7 +2792,7 @@ def evaluate_statements(statements: list[InputAndSystemStatement],
subQueryName=item["subQueryName"])

else:
raise Exception("Dimension or symbolic result not a Matrix for an evaluated expression that is a Matrix")
raise Exception("Internal Error: Dimension or symbolic result not a Matrix for an evaluated expression that is a Matrix. Report error to [email protected]")

if item["isRange"] is True:
current_result = item
Expand Down

0 comments on commit 29ffe31

Please sign in to comment.