From 4f249a1503bef0d69517793992fe2eb5cf1efb7b Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Tue, 17 Sep 2024 09:59:29 +0200 Subject: [PATCH] small updates --- .gitignore | 1 - src/amuse/community/interface/common.py | 65 +++++++++---------------- 2 files changed, 24 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 86281d0f39..d9b5dcd68b 100644 --- a/.gitignore +++ b/.gitignore @@ -406,7 +406,6 @@ test_results/code.c test_results/code.cc test_results/code.f90 gas_interface -interface test_results/interface-sockets.f90 test_results/interface.cc test_results/interface.f90 diff --git a/src/amuse/community/interface/common.py b/src/amuse/community/interface/common.py index b4e3047869..62111592bc 100644 --- a/src/amuse/community/interface/common.py +++ b/src/amuse/community/interface/common.py @@ -8,7 +8,7 @@ from amuse.rfi.core import LegacyFunctionSpecification -class CommonCodeInterface(object): +class CommonCodeInterface: @legacy_function def initialize_code(): @@ -19,13 +19,13 @@ def initialize_code(): """ function = LegacyFunctionSpecification() - function.result_type = 'int32' + function.result_type = "int32" function.result_doc = """ 0 - OK Code is initialized -1 - ERROR Error happened during initialization, this error needs to be - further specified by every code implemention + further specified by every code implementation -2 - ERROR not yet implemented """ @@ -39,13 +39,13 @@ def cleanup_code(): should be called after this code. """ function = LegacyFunctionSpecification() - function.result_type = 'int32' + function.result_type = "int32" function.result_doc = """ 0 - OK Code is initialized -1 - ERROR Error happened during cleanup, this error needs to be further - specified by every code implemention -2 - ERROR + specified by every code implementation -2 - ERROR not yet implemented """ return function @@ -58,13 +58,13 @@ def commit_parameters(): Called after the parameters have been set or updated. """ function = LegacyFunctionSpecification() - function.result_type = 'int32' + function.result_type = "int32" function.result_doc = """ 0 - OK Code is initialized -1 - ERROR Error happened during initialization, this error needs to be - further specified by every code implemention -2 - ERROR + further specified by every code implementation -2 - ERROR not yet implemented """ return function @@ -77,13 +77,13 @@ def recommit_parameters(): particles have been loaded). """ function = LegacyFunctionSpecification() - function.result_type = 'int32' + function.result_type = "int32" function.result_doc = """ 0 - OK Model is initialized and evolution can start -1 - ERROR Error happened during initialization, this error needs to be - further specified by every code implemention """ + further specified by every code implementation """ return function @@ -94,37 +94,20 @@ def invoke_state_change(self): class CommonCode(InCodeComponentImplementation): def define_state(self, handler): - handler.set_initial_state('UNINITIALIZED') - handler.add_transition( - 'UNINITIALIZED', 'INITIALIZED', 'initialize_code') - handler.add_method('INITIALIZED', 'before_get_parameter') - handler.add_method('INITIALIZED', 'before_set_parameter') - handler.add_method('END', 'before_get_parameter') - handler.add_transition('!UNINITIALIZED!STOPPED', 'END', 'cleanup_code') - handler.add_transition('END', 'STOPPED', 'stop', False) - handler.add_method('STOPPED', 'stop') + handler.set_initial_state("UNINITIALIZED") + handler.add_transition("UNINITIALIZED", "INITIALIZED", "initialize_code") + handler.add_method("INITIALIZED", "before_get_parameter") + handler.add_method("INITIALIZED", "before_set_parameter") + handler.add_method("END", "before_get_parameter") + handler.add_transition("!UNINITIALIZED!STOPPED", "END", "cleanup_code") + handler.add_transition("END", "STOPPED", "stop", False) + handler.add_method("STOPPED", "stop") def define_methods(self, handler): - handler.add_method( - 'initialize_code', - (), - (handler.ERROR_CODE) - ) - - handler.add_method( - 'cleanup_code', - (), - (handler.ERROR_CODE) - ) - - handler.add_method( - 'commit_parameters', - (), - (handler.ERROR_CODE) - ) - - handler.add_method( - 'recommit_parameters', - (), - (handler.ERROR_CODE) - ) + handler.add_method("initialize_code", (), (handler.ERROR_CODE)) + + handler.add_method("cleanup_code", (), (handler.ERROR_CODE)) + + handler.add_method("commit_parameters", (), (handler.ERROR_CODE)) + + handler.add_method("recommit_parameters", (), (handler.ERROR_CODE))