filter_blocks¶
- metatensor.filter_blocks(tensor: TensorMap, keys: Labels, copy: bool = False) TensorMap [source]¶
Returns a
TensorMap
with the blocks filtered according to theLabels
key selection passed inkeys
.- 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 tensorTensorMap
.copy (bool) – if
True
, the returnedTensorMap
is constructed by copying the blocks from the input tensor. IfFalse
(default), the values of the blocks in the outputTensorMap
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: