Skip to content

TimeOverflowError(operation_name, type_name) Source

Bases: NumdaplotError

Raised when a value does not fit the nanoseconds counting datetimes and durations.

Without it, the value would become a wrong date or duration without any notice. A DATE is stored in days and can be outside this range, but a calculation on it cannot.

Added in version 0.1.0

Parameters:

Attributes:

  • operation_name

    The operator or the function, such as *, from_list or ToDuration.

  • type_name

    Name of the ndp.Type member that cannot hold the result.

  • column_name (str | None)

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

Examples:

from datetime import timedelta
import numdaplot as ndp

try:
    ndp.Array.from_list([timedelta(days=1)]) * 200000
except ndp.TimeOverflowError as error:
    print(error)
# The operation * gives values outside the range of DURATION, about 292 years before or after zero.

Methods:

write_message(column_text) Source

Return the message, with the range of the type.

Added in version 0.1.0

Parameters:

  • column_text (str)

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

Returns:

  • str

    The message.

Examples:

import numdaplot as ndp

ndp.TimeOverflowError("+", "DATETIME").write_message("")
# 'The operation + gives values outside the range of DATETIME, from 1677 to 2262.'