Skip to content

Truncate array repr based on line count #3760

Closed
@max-sixty

Description

@max-sixty

MCVE Code Sample

I thought we might have had an issue (and maybe solved it?) but couldn't find it anywhere. Forgive me if I'm duplicating.

xr.DataArray(np.random.rand(100,5,1))

<xarray.DataArray (dim_0: 100, dim_1: 5, dim_2: 1)>
array([[[0.71333665],
        [0.93820892],
        [0.48678056],
        [0.07299961],
        [0.63542414]],

*** Deleted 400 lines ***

       [[0.29987457],
        [0.55963998],
        [0.25976744],
        [0.80062955],
        [0.503025  ]],

       [[0.48255097],
        [0.55861315],
        [0.36059861],
        [0.96539665],
        [0.05674621]],

       [[0.81389941],
        [0.55745028],
        [0.20348983],
        [0.63390148],
        [0.94698865]],

       [[0.16792246],
        [0.9252646 ],
        [0.38596734],
        [0.17168077],
        [0.18162088]],

       [[0.04526339],
        [0.70028912],
        [0.72388995],
        [0.97481276],
        [0.66155381]],

       [[0.15058745],
        [0.57646963],
        [0.53382085],
        [0.24696459],
        [0.77601528]],

       [[0.6752243 ],
        [0.84991466],
        [0.87758404],
        [0.70828751],
        [0.04033709]]])
Dimensions without coordinates: dim_0, dim_1, dim_2

Expected Output

With larger arrays, it's much more reasonable:

<xarray.DataArray (dim_0: 500, dim_1: 6, dim_2: 1)>
array([[[0.9680447 ],
        [0.12554914],
        [0.9163406 ],
        [0.63710986],
        [0.97778361],
        [0.6419909 ]],

       [[0.48480678],
        [0.31214637],
        [0.72270997],
        [0.81523543],
        [0.34327902],
        [0.80941523]],

       [[0.92192284],
        [0.47841933],
        [0.00760903],
        [0.83886152],
        [0.88538772],
        [0.6532889 ]],

       ...,

       [[0.39558324],
        [0.42220218],
        [0.56731915],
        [0.27388751],
        [0.51097741],
        [0.62824705]],

       [[0.97379019],
        [0.0311196 ],
        [0.09790975],
        [0.65206508],
        [0.14369363],
        [0.09683937]],

       [[0.71318171],
        [0.88591664],
        [0.30032286],
        [0.97324135],
        [0.10250702],
        [0.03973667]]])
Dimensions without coordinates: dim_0, dim_1, dim_2

Problem Description

Something like 40 lines is probably a reasonable place to truncate?

Output of xr.show_versions()

# Paste the output here xr.show_versions() here INSTALLED VERSIONS ------------------ commit: None python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: [...] machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.utf8 LOCALE: en_US.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.1

xarray: 0.15.0
pandas: 0.25.3
numpy: 1.17.3
scipy: 1.3.2
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.7.0
distributed: 2.7.0
matplotlib: 3.1.2
cartopy: None
seaborn: 0.9.0
numbagg: None
setuptools: 41.6.0.post20191101
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: 2.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions