scipp.full#

scipp.full(*, value, variance=None, dims=None, shape=None, sizes=None, unit=<automatically deduced unit>, dtype=None)#

Constructs a Variable with values initialized to the specified value with given dimension labels and shape.

The dims and shape can also be specified using a sizes dict.

Parameters:
  • value (Any) – The value to fill the Variable with.

  • variance (Any, default: None) – The variance to fill the Variable with.

  • dims (Sequence[str] | None, default: None) – Optional (if sizes is specified), dimension labels.

  • shape (Sequence[int] | None, default: None) – Optional (if sizes is specified), dimension sizes.

  • sizes (dict[str, int] | None, default: None) – Optional, dimension label to size map.

  • unit (Unit | str | DefaultUnit | None, default: <automatically deduced unit>) – Unit of contents.

  • dtype (scipp.typing.DTypeLike) – Type of underlying data.

Returns:

Variable – A variable filled with given value.

Examples

>>> sc.full(value=2, dims=['x'], shape=[2])
<scipp.Variable> (x: 2)      int64  [dimensionless]  [2, 2]
>>> sc.full(value=2, sizes={'x': 2})
<scipp.Variable> (x: 2)      int64  [dimensionless]  [2, 2]
>>> sc.full(value=5, sizes={'y': 3, 'x': 2})
<scipp.Variable> (y: 3, x: 2)      int64  [dimensionless]  [5, 5, ..., 5, 5]
>>> sc.full(value=2.0, variance=0.1, sizes={'x': 3}, unit='s')
<scipp.Variable> (x: 3)    float64              [s]  [2, 2, 2]  [0.1, 0.1, 0.1]