ShapeMismatchError(left_dimensions, right_dimensions)
Source¶
Bases: NumdaplotError
Raised when two shapes do not match.
Two Arrays cannot be combined, a replacement does not fit its region, or a reshape targets a shape holding another number of values.
Added in version 0.1.0
Parameters:
-
left_dimensions(Sequence[int])Dimensions of the first shape.
-
right_dimensions(Sequence[int])Dimensions of the second shape.
Attributes:
-
left_dimensionsDimensions of the first shape, as a list.
-
right_dimensionsDimensions of the second shape, as a list.
Examples:
import numdaplot as ndp
array = ndp.Array.from_list([1, 2, 3])
try:
array.reshape(ndp.Shape([2, 2]))
except ndp.ShapeMismatchError as error:
print(error)
# Expected matching shapes, got [3] and [2, 2].