filter_blocks

metatensor.filter_blocks(tensor: TensorMap, keys: Labels, copy: bool = False) TensorMap[source]

Returns a TensorMap with the blocks filtered according to the Labels key selection passed in keys.

Parameters:
  • tensor (TensorMap) – the TensorMap from which the keys will be selected.

  • keys (Labels) – the Labels containing the keys indexing blocks to retain from the tensor TensorMap.

  • copy (bool) – if True, the returned TensorMap is constructed by copying the blocks from the input tensor. If False (default), the values of the blocks in the output TensorMap reference the same data as the input tensor. The latter can be useful for limiting memory usage, but should be used with caution when manipulating the underlying data.

Return type:

TensorMap