Skip to content

Tupan tests fail with numpy >=2.4.0 #1256

@LourensVeen

Description

@LourensVeen

Describe the bug
The tupan tests fail with numpy >= 2.4.0

To Reproduce
./setup test tupan

Expected behavior
Tests passed

Logs

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

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

    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-2026.3.0/lib/python3.14/site-packages/amuse/rfi/core.py:129: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <amuse.rfi.channel.MpiChannel object at 0x724057d11310>, call_id = 784
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-2026.3.0/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 0x7240eef8cf50>
arguments_list = (), keyword_arguments = {}, dtype_to_values = {}
handle_as_array = False, call_id = 784

    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-2026.3.0/lib/python3.14/site-packages/amuse/rfi/core.py:138: CodeException
----------------------------- Captured stdout call -----------------------------
Test TupanInterface new_particle / get_state

Environment (please complete the following information):

  • OS and version: Ubuntu 24.04
  • Environment: Conda

Additional context
conda install 'numpy<2.4' makes things work again, but is obviously not a long-term solution.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions