Open PicoCentauri opened 3 months ago
When trying to sort an empty TensorBlock
from metatensor.operations import sort_block from metatensor import Labels, TensorBlock empty_block = TensorBlock( samples=Labels.empty(names="samples"), components=[], properties=Labels.single(), values=np.array([]).reshape(-1, 1), ) sort_block(empty_block)
There will be an IndexError:
IndexError
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
See details below for full traceback. However, sorting an empty block should be possible in my opinion.
Thanks to @curiosity54 for finding this issue.
We should have a check if the block is empty and then immediately return. This should be an easy fix!
When trying to sort an empty TensorBlock
There will be an
IndexError
:See details below for full traceback. However, sorting an empty block should be possible in my opinion.
Thanks to @curiosity54 for finding this issue.