scipp.empty(*, dims=None, shape=None, sizes=None, unit=<automatically deduced unit>, dtype=DType('float64'), with_variances=False, aligned=True)#

Constructs a Variable with uninitialized values with given dimension labels and shape.

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


‘Uninitialized’ means that values have undetermined values. Reading elements before writing to them is undefined behavior. Consider using scipp.zeros() unless you know what you are doing and require maximum performance.

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

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

  • sizes (Optional[dict[str, int]], 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.

  • with_variances (bool, default: False) – If True includes uninitialized variances.

  • aligned (bool, default: True) – Initial value for the alignment flag.


Variable – A variable with uninitialized elements.


>>> var = sc.empty(dims=['x'], shape=[4])
>>> var[:] = sc.scalar(2.0)  # initialize values before printing
>>> var
<scipp.Variable> (x: 4)    float64  [dimensionless]  [2, 2, 2, 2]