Skip to content

Tupan fails tests #1230

@LourensVeen

Description

@LourensVeen

Describe the bug
Tupan fails its tests, and I don't recall it doing that before. It doesn't seem to be a change in AMUSE, at least I can reproduce it in 2025.9.0 as well.

Error

$ ./setup test tupan
Checking for dependencies, one moment please...

Testing amuse-tupan...

make: Entering directory '/home/lourens/NLeSC/projects/ReDiTSAp/activities/pr_1227_new_examples/amuse/src/amuse_tupan'
cd packages/amuse-tupan && pytest
============================= test session starts ==============================
platform linux -- Python 3.14.3, pytest-9.0.2, pluggy-1.6.0
rootdir: /home/lourens/NLeSC/projects/ReDiTSAp/activities/pr_1227_new_examples/amuse/src/amuse_tupan/packages/amuse-tupan
configfile: pyproject.toml
testpaths: amuse_tupan/tests
collected 12 items

amuse_tupan/tests/test_tupan.py .FF.F.FFFFFF                             [100%]

=================================== FAILURES ===================================
__________________________ TestTupanInterface.test02 ___________________________

self = <amuse.rfi.core.CodeFunction object at 0x7e42c9ac9050>
arguments_list = (), keyword_arguments = {}, dtype_to_values = {}
handle_as_array = False, call_id = 860

    def __call__(self, *arguments_list, **keyword_arguments):
        if self.interface.async_request:
            try:
                self.interface.async_request.wait()
            except Exception as ex:
                warnings.warn("Ignored exception in async call: " + str(ex))
    
        dtype_to_values = self.converted_keyword_and_list_arguments(
            arguments_list, keyword_arguments
        )
    
        handle_as_array = self.must_handle_as_array(dtype_to_values)
    
        if not self.owner is None:
            CODE_LOG.info(
                "start call '%s.%s'", self.owner.__name__, self.specification.name
            )
    
        call_id = random.randint(0, 1000)
    
        try:
            self.interface.channel.send_message(
                call_id, self.specification.id, dtype_to_arguments=dtype_to_values
            )
    
>           dtype_to_result = self.interface.channel.recv_message(
                call_id, self.specification.id, handle_as_array
            )

/home/lourens/.miniconda3/envs/amuse-pr-1227/lib/python3.14/site-packages/amuse/rfi/core.py:129: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <amuse.rfi.channel.MpiChannel object at 0x7e42344d9090>, call_id = 860
function_id = 20920053, handle_as_array = False, has_units = False

    def recv_message(self, call_id, function_id, handle_as_array, has_units=False):
    
        if self._communicated_splitted_message:
            x = self._merged_results_splitted_message
            self._communicated_splitted_message = False
            del self._merged_results_splitted_message
            return x
    
        message = ServerSideMPIMessage(
            polling_interval=self.polling_interval_in_milliseconds * 1000
        )
        try:
            message.receive(self.intercomm)
        except MPI.Exception as ex:
            self._is_inuse = False
            self.stop()
            raise ex
        self.inuse_semaphore.acquire()
        try:
            if not self._is_inuse:
                raise exceptions.CodeException(
                    "You've tried to recv a message to a code that is not handling a message, this is not correct"
                )
            self._is_inuse = False
        finally:
            self.inuse_semaphore.release()
    
        if message.error:
            error_message = (
                message.strings[0] if len(message.strings) > 0 else "no error message"
            )
            if message.call_id != call_id or message.function_id != function_id:
                self.stop()
                error_message += " - code probably died, sorry."
>           raise exceptions.CodeException("Error in code: " + error_message)
E           amuse.support.exceptions.CodeException: Error in code: setting an array element with a sequence.

/home/lourens/.miniconda3/envs/amuse-pr-1227/lib/python3.14/site-packages/amuse/rfi/channel.py:1361: CodeException

During handling of the above exception, another exception occurred:

self = <test_tupan.TestTupanInterface testMethod=test02>

    def test02(self):
        if MODULES_MISSING:
            self.skip("Failed to import a module required for Tupan")
        print("Test TupanInterface new_particle / get_state")
        instance = self.new_instance_of_an_optional_code(TupanInterface)
        self.assertEqual(0, instance.initialize_code())
        self.assertEqual(0, instance.commit_parameters())
    
        id, error = instance.new_particle(mass=11.0, radius=2.0, x=0.0, y=0.0, z=0.0, vx=0.0, vy=0.0, vz=0.0)
        self.assertEqual(0, error)
        self.assertEqual(0, id)
        id, error = instance.new_particle(mass=21.0, radius=5.0, x=10.0, y=0.0, z=0.0, vx=10.0, vy=0.0, vz=0.0)
        self.assertEqual(0, error)
        self.assertEqual(1, id)
>       self.assertEqual(0, instance.commit_particles())
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^

amuse_tupan/tests/test_tupan.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <amuse.rfi.core.CodeFunction object at 0x7e42c9ac9050>
arguments_list = (), keyword_arguments = {}, dtype_to_values = {}
handle_as_array = False, call_id = 860

    def __call__(self, *arguments_list, **keyword_arguments):
        if self.interface.async_request:
            try:
                self.interface.async_request.wait()
            except Exception as ex:
                warnings.warn("Ignored exception in async call: " + str(ex))
    
        dtype_to_values = self.converted_keyword_and_list_arguments(
            arguments_list, keyword_arguments
        )
    
        handle_as_array = self.must_handle_as_array(dtype_to_values)
    
        if not self.owner is None:
            CODE_LOG.info(
                "start call '%s.%s'", self.owner.__name__, self.specification.name
            )
    
        call_id = random.randint(0, 1000)
    
        try:
            self.interface.channel.send_message(
                call_id, self.specification.id, dtype_to_arguments=dtype_to_values
            )
    
            dtype_to_result = self.interface.channel.recv_message(
                call_id, self.specification.id, handle_as_array
            )
        except Exception as ex:
            CODE_LOG.info(
                "Exception when calling function '{0}', of code '{1}', exception was '{2}'".format(
                    self.specification.name, type(self.interface).__name__, ex
                )
            )
>           raise exceptions.CodeException(
                "Exception when calling function '{0}', of code '{1}', exception was '{2}'".format(
                    self.specification.name, type(self.interface).__name__, ex
                )
            )
E           amuse.support.exceptions.CodeException: Exception when calling function 'commit_particles', of code 'TupanInterface', exception was 'Error in code: setting an array element with a sequence.'

/home/lourens/.miniconda3/envs/amuse-pr-1227/lib/python3.14/site-packages/amuse/rfi/core.py:138: CodeException
----------------------------- Captured stdout call -----------------------------

The other tests fail with the same message.

Related: #793

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions