(arr)
| 717 | |
| 718 | @recursive_repr("<recursive array>") |
| 719 | def array_repr(arr): |
| 720 | from xarray.core.variable import Variable |
| 721 | |
| 722 | max_rows = OPTIONS["display_max_rows"] |
| 723 | |
| 724 | # used for DataArray, Variable and IndexVariable |
| 725 | if hasattr(arr, "name") and arr.name is not None: |
| 726 | name_str = f"{arr.name!r} " |
| 727 | else: |
| 728 | name_str = "" |
| 729 | |
| 730 | if ( |
| 731 | isinstance(arr, Variable) |
| 732 | or _get_boolean_with_default("display_expand_data", default=True) |
| 733 | or isinstance(arr.variable._data, MemoryCachedArray) |
| 734 | ): |
| 735 | data_repr = short_data_repr(arr) |
| 736 | else: |
| 737 | data_repr = inline_variable_array_repr(arr.variable, OPTIONS["display_width"]) |
| 738 | |
| 739 | start = f"<xarray.{type(arr).__name__} {name_str}" |
| 740 | dims = dim_summary_limited(arr.sizes, col_width=len(start) + 1, max_rows=max_rows) |
| 741 | nbytes_str = render_human_readable_nbytes(arr.nbytes) |
| 742 | summary = [ |
| 743 | f"{start}({dims})> Size: {nbytes_str}", |
| 744 | data_repr, |
| 745 | ] |
| 746 | if hasattr(arr, "coords"): |
| 747 | if arr.coords: |
| 748 | col_width = _calculate_col_width(arr.coords) |
| 749 | summary.append( |
| 750 | coords_repr(arr.coords, col_width=col_width, max_rows=max_rows) |
| 751 | ) |
| 752 | |
| 753 | unindexed_dims_str = unindexed_dims_repr( |
| 754 | arr.dims, arr.coords, max_rows=max_rows |
| 755 | ) |
| 756 | if unindexed_dims_str: |
| 757 | summary.append(unindexed_dims_str) |
| 758 | |
| 759 | display_default_indexes = _get_boolean_with_default( |
| 760 | "display_default_indexes", False |
| 761 | ) |
| 762 | |
| 763 | xindexes = filter_nondefault_indexes( |
| 764 | _get_indexes_dict(arr.xindexes), not display_default_indexes |
| 765 | ) |
| 766 | |
| 767 | if xindexes: |
| 768 | summary.append(indexes_repr(xindexes, max_rows=max_rows)) |
| 769 | |
| 770 | if arr.attrs: |
| 771 | summary.append(attrs_repr(arr.attrs, max_rows=max_rows)) |
| 772 | |
| 773 | return "\n".join(summary) |
| 774 | |
| 775 | |
| 776 | @recursive_repr("<recursive Dataset>") |
nothing calls this directly
no test coverage detected
searching dependent graphs…