Check if two list of arguments are exactly the same.
(n1, n2)
| 986 | |
| 987 | |
| 988 | def check_mutation(n1, n2): |
| 989 | """Check if two list of arguments are exactly the same.""" |
| 990 | errmsg = ("Function to be traced should not modify structure of input " |
| 991 | "arguments. Check if your function has list and dictionary " |
| 992 | "operations that alter input arguments, " |
| 993 | "such as `list.pop`, `list.append`") |
| 994 | try: |
| 995 | nest.assert_same_structure(n1, n2, expand_composites=True) |
| 996 | except ValueError: |
| 997 | raise ValueError(errmsg) |
| 998 | |
| 999 | for arg1, arg2 in zip(nest.flatten(n1, expand_composites=True), |
| 1000 | nest.flatten(n2, expand_composites=True)): |
| 1001 | if arg1 is not arg2: |
| 1002 | raise ValueError(errmsg) |
| 1003 | |
| 1004 | |
| 1005 | # TODO(edloper): If TensorArray becomes a CompositeTensor, then delete this. |
no test coverage detected