InvalidPositionError(position, size=None, lowest=0)
Source¶
Bases: NumdaplotError
Raised when a position falls outside its dimension.
A dimension of size 5 accepts the positions from -5 to 4. Without a size, as when an Index or a Cell is
created, the message names the lowest accepted position.
Added in version 0.1.0
Parameters:
-
position(object)The rejected position.
-
size(int | None, default:None)Size of the dimension. When omitted, the size is not known yet, as when an
Indexis created. -
lowest(int, default:0)The lowest accepted position, named when the size is not known, 0 by default.
Attributes:
-
positionThe rejected position.
-
sizeSize of the dimension, or None.
-
lowestThe lowest accepted position.
Examples:
import numdaplot as ndp
array = ndp.Array.from_list([1, 2, 3])
try:
array.take(ndp.Region(rows=ndp.Index(5)))
except ndp.InvalidPositionError as error:
print(error)
# Expected a whole position between -3 and 2, got 5.