assert_same_ndim: Assert that Shapes have the Same Number of Dimensions

View source: R/shape.R

assert_same_ndimR Documentation

Assert that Shapes have the Same Number of Dimensions

Description

Rejects inputs that do not all have the same number of dimensions, which the operators that combine several inputs require: shorter shapes are not left-padded with 1s, because the first dimension is the batch dimension.

Usage

assert_same_ndim(shapes, id)

Arguments

shapes

(list() of integer())
The input shapes.

id

(character(1))
The id of the PipeOp, which the error message names.

Value

The shapes, invisibly.

See Also

Other Shape Assertions: assert_dim_in_range(), assert_known_dims(), assert_ndim(), assert_not_batch_dim(), assert_positive_extent(), assert_same_batch_size(), assert_shape(), assert_shapes()

Examples

assert_same_ndim(list(c(NA, 3), c(NA, 5)), id = "nn_merge_cat")
try(assert_same_ndim(list(c(NA, 3), c(NA, 5, 2)), id = "nn_merge_cat"))

mlr3torch documentation built on Oct. 30, 2026, 5:10 p.m.