Skip to contents

Removes axes of size 1 from an array.

Usage

nv_squeeze(x, axes = NULL)

Arguments

x

(arrayish)
One input. Can be any data type. An R value materializes at its default data type.

axes

(integer() | NULL)
Axes to squeeze. Negative values count from the end, i.e. -1 refers to the last axis. If NULL (default), all axes of size 1 are removed.

Value

(arrayish)
Has x's data type, with the specified axes removed from its shape.

Examples

# the two size-1 axes are dropped
x <- nv_array(1:6, shape = c(1, 6, 1))
nv_squeeze(x)
#> AnvlArray
#>  1
#>  2
#>  3
#>  4
#>  5
#>  6
#> [ CPUi32{6} ]