filter_blocks¶
- metatensor.filter_blocks(tensor: TensorMap, keys: Labels, copy: bool = False) TensorMap[source]¶
Returns a
TensorMapwith the blocks filtered according to theLabelskey selection passed inkeys.- Parameters:
tensor (TensorMap) – the
TensorMapfrom which the keys will be selected.keys (Labels) – the
Labelscontaining the keys indexing blocks to retain from the tensorTensorMap.copy (bool) – if
True, the returnedTensorMapis constructed by copying the blocks from the input tensor. IfFalse(default), the values of the blocks in the outputTensorMapreference 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: