"""
Test node multiplying tuple arrays by a constant
"""
import numpy as np


class OgnTestTupleArrays:
    """Exercise a sample of complex data types through a Python OmniGraph node"""

    @staticmethod
    def compute(db) -> bool:
        """Multiply every value in a tuple array by a constant."""

        multiplier = db.inputs.multiplier
        input_array = db.inputs.float3Array
        input_array_size = len(db.inputs.float3Array)

        db.outputs.float3Array_size = input_array_size

        # If the input array is empty then the output is empty and does not need any computing
        if input_array.shape[0] == 0:
            db.outputs.float3Array = []
            assert db.outputs.float3Array.shape == (0, 3)
            return True

        db.outputs.float3Array = np.multiply(input_array, multiplier)

        return True
