(a, b, compat)
| 1054 | |
| 1055 | |
| 1056 | def diff_array_repr(a, b, compat): |
| 1057 | # used for DataArray, Variable and IndexVariable |
| 1058 | summary = [ |
| 1059 | f"Left and right {type(a).__name__} objects are not {_compat_to_str(compat)}" |
| 1060 | ] |
| 1061 | |
| 1062 | if dims_diff := diff_dim_summary(a, b): |
| 1063 | summary.append(dims_diff) |
| 1064 | |
| 1065 | if callable(compat): |
| 1066 | equiv = compat |
| 1067 | else: |
| 1068 | equiv = array_equiv |
| 1069 | |
| 1070 | if not equiv(a.data, b.data): |
| 1071 | temp = [wrap_indent(short_array_repr(obj), start=" ") for obj in (a, b)] |
| 1072 | diff_data_repr = [ |
| 1073 | ab_side + "\n" + ab_data_repr |
| 1074 | for ab_side, ab_data_repr in zip(("L", "R"), temp, strict=True) |
| 1075 | ] |
| 1076 | summary += ["Differing values:"] + diff_data_repr |
| 1077 | |
| 1078 | if hasattr(a, "coords"): |
| 1079 | col_width = _calculate_col_width(set(a.coords) | set(b.coords)) |
| 1080 | if coords_diff := diff_coords_repr( |
| 1081 | a.coords, b.coords, compat, col_width=col_width |
| 1082 | ): |
| 1083 | summary.append(coords_diff) |
| 1084 | |
| 1085 | if compat == "identical": |
| 1086 | if hasattr(a, "xindexes") and ( |
| 1087 | indexes_diff := diff_indexes_repr(a.xindexes, b.xindexes) |
| 1088 | ): |
| 1089 | summary.append(indexes_diff) |
| 1090 | |
| 1091 | if attrs_diff := diff_attrs_repr(a.attrs, b.attrs, compat): |
| 1092 | summary.append(attrs_diff) |
| 1093 | |
| 1094 | return "\n".join(summary) |
| 1095 | |
| 1096 | |
| 1097 | def diff_treestructure(a: DataTree, b: DataTree) -> str | None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…