Skip to content

Shape(dimensions) Source

Number of values along each dimension of an Array or a Table.

Shape([3, 4]) describes 3 rows of 4 values, and Shape([5]) a single row of 5 values. It is used by Array.filled, Array.random and reshape, and returned by Array.shape and Table.shape, which gives the number of rows, then the number of columns.

Changed in version 0.2.0

Also describes the rows and columns of a Table, returned by Table.shape.

Version history (1)

Added in version 0.1.0

Parameters:

  • dimensions (list[int])

    Number of values along each dimension, a list of at least one dimension and none lower than 0. The shape keeps its own copy of the list.

Raises:

Examples:

import numdaplot as ndp

ndp.Array.filled(shape=ndp.Shape([2, 3]), value=0)
# Array([[0, 0, 0],
#        [0, 0, 0]], dtype=INT64)
ndp.Array.from_list([[1, 2, 3], [4, 5, 6]]).shape
# Shape(dimensions=[2, 3])
ndp.Table.from_arrays({"price": ndp.Array.from_list([1.5, 8.0, 3.0])}).shape
# Shape(dimensions=[3, 1])