From dc9e83b640de319b093c72f0f8afaa1c3d93cba3 Mon Sep 17 00:00:00 2001 From: Levin Schmidt Date: Wed, 17 May 2023 08:58:37 +0200 Subject: [PATCH 1/2] Moved from "==" to "equals" comparison --- pynestml/symbols/unit_type_symbol.py | 2 +- pynestml/utils/ast_utils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pynestml/symbols/unit_type_symbol.py b/pynestml/symbols/unit_type_symbol.py index 9dc21f9ff..37c43b035 100644 --- a/pynestml/symbols/unit_type_symbol.py +++ b/pynestml/symbols/unit_type_symbol.py @@ -48,7 +48,7 @@ def print_nestml_type(self): def equals(self, other=None): basic_equals = super(UnitTypeSymbol, self).equals(other) if basic_equals is True: - return self.unit == other.unit + return self.unit.equals(other.unit) return False diff --git a/pynestml/utils/ast_utils.py b/pynestml/utils/ast_utils.py index 9889326ab..21bc556ec 100644 --- a/pynestml/utils/ast_utils.py +++ b/pynestml/utils/ast_utils.py @@ -1303,13 +1303,13 @@ def is_delta_kernel(cls, kernel: ASTKernel) -> bool: rhs_is_delta_kernel = type(expr) is ASTSimpleExpression \ and expr.is_function_call() \ and expr.get_function_call().get_scope().resolve_to_symbol( - expr.get_function_call().get_name(), SymbolKind.FUNCTION) == PredefinedFunctions.name2function["delta"] + expr.get_function_call().get_name(), SymbolKind.FUNCTION).equals(PredefinedFunctions.name2function["delta"]) rhs_is_multiplied_delta_kernel = type(expr) is ASTExpression \ and type(expr.get_rhs()) is ASTSimpleExpression \ and expr.get_rhs().is_function_call() \ and expr.get_rhs().get_function_call().get_scope().resolve_to_symbol( - expr.get_rhs().get_function_call().get_name(), SymbolKind.FUNCTION) == PredefinedFunctions.name2function[ - "delta"] + expr.get_rhs().get_function_call().get_name(), SymbolKind.FUNCTION).equals(PredefinedFunctions.name2function[ + "delta"]) return rhs_is_delta_kernel or rhs_is_multiplied_delta_kernel @classmethod From 5005529412eafe74f158c90eb20a1a516bc47dc5 Mon Sep 17 00:00:00 2001 From: "C.A.P. Linssen" Date: Thu, 22 Jun 2023 05:30:05 -0700 Subject: [PATCH 2/2] fix static code check --- pynestml/utils/ast_utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pynestml/utils/ast_utils.py b/pynestml/utils/ast_utils.py index 21bc556ec..8daf6c43b 100644 --- a/pynestml/utils/ast_utils.py +++ b/pynestml/utils/ast_utils.py @@ -1302,14 +1302,11 @@ def is_delta_kernel(cls, kernel: ASTKernel) -> bool: rhs_is_delta_kernel = type(expr) is ASTSimpleExpression \ and expr.is_function_call() \ - and expr.get_function_call().get_scope().resolve_to_symbol( - expr.get_function_call().get_name(), SymbolKind.FUNCTION).equals(PredefinedFunctions.name2function["delta"]) + and expr.get_function_call().get_scope().resolve_to_symbol(expr.get_function_call().get_name(), SymbolKind.FUNCTION).equals(PredefinedFunctions.name2function["delta"]) rhs_is_multiplied_delta_kernel = type(expr) is ASTExpression \ and type(expr.get_rhs()) is ASTSimpleExpression \ and expr.get_rhs().is_function_call() \ - and expr.get_rhs().get_function_call().get_scope().resolve_to_symbol( - expr.get_rhs().get_function_call().get_name(), SymbolKind.FUNCTION).equals(PredefinedFunctions.name2function[ - "delta"]) + and expr.get_rhs().get_function_call().get_scope().resolve_to_symbol(expr.get_rhs().get_function_call().get_name(), SymbolKind.FUNCTION).equals(PredefinedFunctions.name2function["delta"]) return rhs_is_delta_kernel or rhs_is_multiplied_delta_kernel @classmethod