Skip to content

example_fgen_basic.error_v.creation#

Wrappers of m_error_v_creation

At the moment, all written by hand. We will auto-generate this in future.

Functions:

Name Description
create_error

Create an error

create_errors

Create a number of errors

create_error #

create_error(inv: int) -> ErrorV

Create an error

Parameters:

Name Type Description Default
inv int

Input value

If odd, the error code is NO_ERROR_CODE. If even, the error code is 1. If a negative number is supplied, the error code is 2.

required

Returns:

Type Description
ErrorV

Created error

Source code in src/example_fgen_basic/error_v/creation.py
def create_error(inv: int) -> ErrorV:
    """
    Create an error

    Parameters
    ----------
    inv
        Input value

        If odd, the error code is
        [NO_ERROR_CODE][example_fgen_basic.error_v.error_v.NO_ERROR_CODE].
        If even, the error code is 1.
        If a negative number is supplied, the error code is 2.

    Returns
    -------
    :
        Created error
    """
    # Get the result, but receiving an instance index rather than the object itself
    instance_index: int = m_error_v_creation_w.create_error(inv)

    # Initialise the result from the received index
    res = ErrorV.from_instance_index(instance_index)

    # Tell Fortran to finalise the object on the Fortran side
    # (all data has been copied to Python now)
    m_error_v_w.finalise_instance(instance_index)

    return res

create_errors #

create_errors(invs: NP_ARRAY_OF_INT) -> tuple[ErrorV, ...]

Create a number of errors

Parameters:

Name Type Description Default
invs NP_ARRAY_OF_INT

Input values from which to create errors

For each value in invs, if the value is even, an error is created, if the value is odd, an error with a no error code is created.

required

Returns:

Type Description
tuple[ErrorV, ...]

Created errors

Source code in src/example_fgen_basic/error_v/creation.py
def create_errors(invs: NP_ARRAY_OF_INT) -> tuple[ErrorV, ...]:
    """
    Create a number of errors

    Parameters
    ----------
    invs
        Input values from which to create errors

        For each value in `invs`,
        if the value is even, an error is created,
        if the value is odd, an error with a no error code is created.

    Returns
    -------
    :
        Created errors
    """
    # Get the result, but receiving an instance index rather than the object itself
    instance_indexes: NP_ARRAY_OF_INT = m_error_v_creation_w.create_errors(invs)

    # Initialise the result from the received index
    res = tuple(ErrorV.from_instance_index(i) for i in instance_indexes)

    # Tell Fortran to finalise the object on the Fortran side
    # (all data has been copied to Python now)
    m_error_v_w.finalise_instances(instance_indexes)

    return res