declearn.test_utils.assert_dict_equal
Assert that two (possibly nested) dicts are equal.
This function is a more complex equivalent of assert dict_a == dict_b
that enables comparing numpy array values, and optionally accepting to
cast tuples as lists rather than assert that a tuple and a list are not
equal in any case (even when their contents are the same).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dict_a |
Dict[str, Any]
|
First dict to compare. |
required |
dict_b |
Dict[str, Any]
|
Second dict to compare. |
required |
strict_tuple |
bool
|
Whether to cast tuples to list prior to comparing them (enabling some tuple-list type differences between the two compared dicts). |
False
|
np_tolerance |
Optional[float]
|
Optional absolute tolerance to numpy arrays or float values'
differences (use |
None
|
Raises:
Type | Description |
---|---|
AssertionError
|
If the two dicts are not equal. |
Source code in declearn/test_utils/_assertions.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|