IntegerOverflowError(operation_name, type_name)
Source¶
Bases: NumdaplotError
Raised when an integer result does not fit its type, which would otherwise wrap around to a wrong number.
The message gives the range of the type and advises INT64 for smaller integers, FLOAT64 for INT64 and
UINT64, which have no wider integer type.
Changed in version 0.2.0
The message gives the range of the type and advises INT64 for smaller integers. It names the type of the
Array when a number written before an operator does not fit it.
Version history (1)
Added in version 0.1.0
Parameters:
-
operation_name(str)The operator or the statistic, such as
*orSum. -
type_name(str)Name of the integer
ndp.Typemember that cannot hold the result.
Attributes:
-
operation_nameThe operator or the statistic, such as
*orSum. -
type_nameName of the integer
ndp.Typemember that cannot hold the result.
Examples:
import numdaplot as ndp
try:
ndp.Array.from_list([2**62]) * 4
except ndp.IntegerOverflowError as error:
print(error)
# The operation * gives values outside the range of INT64, from -9223372036854775808 to 9223372036854775807.
# Convert the values to FLOAT64 first, which keeps about 16 digits.
small_counts = ndp.Table.from_arrays({"count": ndp.Array.from_list([1, 2])})
small_counts = small_counts.convert(ndp.TableConversion(columns=["count"], dtype=ndp.Type.UINT8))
try:
small_counts.column("count") - 5
except ndp.IntegerOverflowError as error:
print(error)
# The operation - gives values outside the range of UINT8, from 0 to 255. Convert the values to INT64 first.