Checks#
Metatensor performs shape as well as consistency checks for the metadata during each operation.
There are plans to enable and disable the checks with the functions documented here to bypass some of them, but they are not currently implemented.
- metatensor.checks_enabled() bool [source]#
Check status if metatensor checks should be performed.
- Return type:
- metatensor.unsafe_disable_checks()[source]#
Disable metatensor checks.
Calling this function permanently disables all metatensor operations checks.
>>> import metatensor >>> metatensor.unsafe_disable_checks() checks disabled >>> print(metatensor.checks_enabled()) False
You can also use a compound statement to disable checks only temporarily.
>>> metatensor.unsafe_enable_checks() checks enabled >>> with metatensor.unsafe_disable_checks(): ... # checks are disabled here ... print(metatensor.checks_enabled()) ... False >>> print(metatensor.checks_enabled()) True
- metatensor.unsafe_enable_checks()[source]#
Enable metatensor checks.
Checks are default enabled. Calling this function permanently enables all metatensor operations checks.
>>> import metatensor >>> metatensor.unsafe_enable_checks() checks enabled >>> print(metatensor.checks_enabled()) True
You can also use a compound statement to enable checks only temporarily. This can be useful in nested constructions.
>>> import metatensor >>> print(metatensor.checks_enabled()) True >>> with metatensor.unsafe_disable_checks(): ... # checks are disabled here ... print(metatensor.checks_enabled()) ... with metatensor.unsafe_enable_checks(): ... # checks enabled here again ... print(metatensor.checks_enabled()) ... False True >>> print(metatensor.checks_enabled()) True