Skip to content

OutOfDomainError(function_name, value, between_integers=False) Source

Bases: NumdaplotError

Raised when a math function or an operator receives a value it is not defined for.

For example, the square root of a negative number, the logarithm of 0, or an integer divided by 0 with //.

Changed in version 0.2.0

The message names the Table column holding the value.

Version history (1)

Added in version 0.1.0

Parameters:

  • function_name (str)

    Name of the math function.

  • value (float)

    The first value outside the domain of the function.

  • between_integers (bool, default: False)

    True when decimals would accept the value, False by default.

Attributes:

  • function_name

    Name of the math function.

  • value

    The first value outside the domain of the function.

  • between_integers

    True when decimals would accept the value.

  • column_name (str | None)

    Name of the Table column holding the value, or None for the values of an Array.

Examples:

import numdaplot as ndp

array = ndp.Array.from_list([4, -9])
try:
    array.apply(ndp.SquareRoot())
except ndp.OutOfDomainError as error:
    print(error)
# SquareRoot is not defined for -9.

Methods:

write_message(column_text) Source

Return the message, with the advice to convert integers when decimals would accept the value.

Added in version 0.2.0

Parameters:

  • column_text (str)

    The words naming the column after the value, or an empty text.

Returns:

  • str

    The message.

Examples:

import numdaplot as ndp

ndp.OutOfDomainError("Logarithm", 0).write_message("")
# 'Logarithm is not defined for 0.'