scipp.empty#

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

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

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

Warning

‘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.

Parameters
  • 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], default: None) – Optional, dimension label to size map.

  • unit (Union[Unit, str, 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.

Examples

>>> 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]
Return type

Variable