(node: DataTree, root: bool)
| 1183 | |
| 1184 | |
| 1185 | def _datatree_node_repr(node: DataTree, root: bool) -> str: |
| 1186 | summary = [f"Group: {node.path}"] |
| 1187 | |
| 1188 | col_width = _calculate_col_width(node.variables) |
| 1189 | max_rows = OPTIONS["display_max_rows"] |
| 1190 | |
| 1191 | inherited_coords = inherited_vars(node._coord_variables) |
| 1192 | |
| 1193 | # Only show dimensions if also showing a variable or coordinates section. |
| 1194 | show_dims = ( |
| 1195 | node._node_coord_variables |
| 1196 | or (root and inherited_coords) |
| 1197 | or node._data_variables |
| 1198 | ) |
| 1199 | |
| 1200 | dim_sizes = node.sizes if root else node._node_dims |
| 1201 | |
| 1202 | if show_dims: |
| 1203 | # Includes inherited dimensions. |
| 1204 | dims_start = pretty_print("Dimensions:", col_width) |
| 1205 | dims_values = dim_summary_limited( |
| 1206 | dim_sizes, col_width=col_width + 1, max_rows=max_rows |
| 1207 | ) |
| 1208 | summary.append(f"{dims_start}({dims_values})") |
| 1209 | |
| 1210 | if node._node_coord_variables: |
| 1211 | node_coords = node.to_dataset(inherit=False).coords |
| 1212 | summary.append(coords_repr(node_coords, col_width=col_width, max_rows=max_rows)) |
| 1213 | |
| 1214 | if root and inherited_coords: |
| 1215 | summary.append( |
| 1216 | inherited_coords_repr(node, col_width=col_width, max_rows=max_rows) |
| 1217 | ) |
| 1218 | |
| 1219 | if show_dims: |
| 1220 | unindexed_dims_str = unindexed_dims_repr( |
| 1221 | dim_sizes, node.coords, max_rows=max_rows |
| 1222 | ) |
| 1223 | if unindexed_dims_str: |
| 1224 | summary.append(unindexed_dims_str) |
| 1225 | |
| 1226 | if node._data_variables: |
| 1227 | summary.append( |
| 1228 | data_vars_repr(node._data_variables, col_width=col_width, max_rows=max_rows) |
| 1229 | ) |
| 1230 | |
| 1231 | # TODO: only show indexes defined at this node, with a separate section for |
| 1232 | # inherited indexes (if root=True) |
| 1233 | display_default_indexes = _get_boolean_with_default( |
| 1234 | "display_default_indexes", False |
| 1235 | ) |
| 1236 | xindexes = filter_nondefault_indexes( |
| 1237 | _get_indexes_dict(node.xindexes), not display_default_indexes |
| 1238 | ) |
| 1239 | if xindexes: |
| 1240 | summary.append(indexes_repr(xindexes, max_rows=max_rows)) |
| 1241 | |
| 1242 | if node.attrs: |
no test coverage detected
searching dependent graphs…