equal

metatensor.equal(tensor_1: TensorMap, tensor_2: TensorMap) bool[source]

Compare two TensorMap.

This function returns True if the two tensors have the same keys (potentially in different order) and all the TensorBlock have the same (and in the same order) samples, components, properties, and their their values are strictly equal.

The TensorMap contains gradient data, then this function only returns True if all the gradients also have the same samples, components, properties and their their values are strictly equal.

In practice this function calls equal_raise(), returning True if no exception is raised, False otherwise.

Parameters:
Return type:

bool

metatensor.equal_raise(tensor_1: TensorMap, tensor_2: TensorMap) None[source]

Compare two TensorMap, raising NotEqualError if they are not the same.

The message associated with the exception will contain more information on where the two TensorMap differ. See equal() for more information on which TensorMap are considered equal.

Raises:

metatensor.NotEqualError if the blocks are different

Parameters:
Return type:

None

metatensor.equal_block(block_1: TensorBlock, block_2: TensorBlock) bool[source]

Compare two TensorBlock.

This function returns True if the two TensorBlock have the same samples, components, properties and their values are strictly equal.

If the TensorBlock contains gradients, then the gradient must also have same (and in the same order) samples, components, properties and their values are strictly equal.

In practice this function calls equal_block_raise(), returning True if no exception is raised, False otherwise.

Parameters:
Return type:

bool

metatensor.equal_block_raise(block_1: TensorBlock, block_2: TensorBlock) None[source]

Compare two TensorBlock, raising metatensor.NotEqualError if they are not the same.

The message associated with the exception will contain more information on where the two TensorBlock differ. See equal_block() for more information on which TensorBlock are considered equal.

Raises:

metatensor.NotEqualError if the blocks are different

Parameters:
Return type:

None

metatensor.NotEqualError()[source]

Exception used to indicate that two metatensor objects are different