From c0df001f196655dd5b3ada6f1fa3909b90584abd Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Fri, 25 Apr 2025 12:59:07 +0200 Subject: [PATCH] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Frederik Hennig <frederik.hennig@fau.de> --- .../backend/reduction_op_mapping.py | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/pystencils/backend/reduction_op_mapping.py b/src/pystencils/backend/reduction_op_mapping.py index 832f5d0bf..59273efab 100644 --- a/src/pystencils/backend/reduction_op_mapping.py +++ b/src/pystencils/backend/reduction_op_mapping.py @@ -12,27 +12,20 @@ _available_operator_interface: set[ReductionOp] = { def reduction_op_to_expr(op: ReductionOp, op1, op2) -> PsExpression: - if op in _available_operator_interface: - match op: - case ReductionOp.Add: - return PsAdd(op1, op2) - case ReductionOp.Sub: - return PsSub(op1, op2) - case ReductionOp.Mul: - return PsMul(op1, op2) - case ReductionOp.Div: - return PsDiv(op1, op2) - case _: - raise FreezeError( - f"Found unsupported operation type for reduction assignments: {op}." - ) - else: - match op: - case ReductionOp.Min: - return PsCall(PsMathFunction(MathFunctions.Min), [op1, op2]) - case ReductionOp.Max: - return PsCall(PsMathFunction(MathFunctions.Max), [op1, op2]) - case _: - raise FreezeError( - f"Found unsupported operation type for reduction assignments: {op}." - ) + match op: + case ReductionOp.Add: + return PsAdd(op1, op2) + case ReductionOp.Sub: + return PsSub(op1, op2) + case ReductionOp.Mul: + return PsMul(op1, op2) + case ReductionOp.Div: + return PsDiv(op1, op2) + case ReductionOp.Min: + return PsCall(PsMathFunction(MathFunctions.Min), [op1, op2]) + case ReductionOp.Max: + return PsCall(PsMathFunction(MathFunctions.Max), [op1, op2]) + case _: + raise FreezeError( + f"Found unsupported operation type for reduction assignments: {op}." + ) -- GitLab