test#
Source code: sensai/util/test.py
- SNAPSHOT_FLOAT_DECIMALS_DEFAULT = 6#
The default number of float decimal places to consider when converting to a snapshot. Overwrite this constant in user code if you want to change the default for all calls to snapshot_compatible
- SNAPSHOT_SIGNIFICANT_DIGITS_DEFAULT = 12#
The (maximum) number of significant digits to consider when converting to a snapshot. Overwrite this constant in user code if you want to change the default for all calls to snapshot_compatible
- snapshot_compatible(obj, float_decimals: Optional[int] = None, significant_digits: Optional[int] = None)[source]#
Renders an object snapshot-compatible by appropriately converting nested types and reducing float precision to a level that is likely to not cause problems when testing snapshots for equivalence on different platforms. Works with many standard python, numpy and pandas objects, including arrays and data frames.
- Parameters:
obj – the object to convert
float_decimals – the number of float decimal places to consider, by default it is 6 (see SNAPSHOT_FLOAT_DECIMALS_DEFAULT)
significant_digits – the (maximum) number of significant digits to consider, by default it is 12 (see SNAPSHOT_SIGNIFICANT_DIGITS_DEFAULT)
- Returns:
the converted object