Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "Size: " prefix in Dataset and DataArray repr + add option to show nbytes on individual variables #9078

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions doc/user-guide/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Xarray offers a small number of configuration options through :py:func:`set_opti
- ``display_expand_data_vars``
- ``display_max_rows``
- ``display_style``
- ``display_variables_nbytes``

2. Control behaviour during operations: ``arithmetic_join``, ``keep_attrs``, ``use_bottleneck``.
3. Control colormaps for plots:``cmap_divergent``, ``cmap_sequential``.
Expand Down
9 changes: 9 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ v2024.05.1 (unreleased)
New Features
~~~~~~~~~~~~

- Removed the "Size: " prefix before the ``nbytes`` in the ``DataArray`` and ``Dataset`` representations,
and added a ``display_variables_nbytes`` option to show or hide the ``nbytes`` of individual variables
in the ``DataArray`` and ``Dataset`` representations. The option can take one of those values:
* ``True`` : to always show the nbytes for variables
* ``False`` : to always hide the nbytes for variables
* ``default`` : to only show the nbytes for lazy variables (e.g. dask arrays)
(:issue:`8690`, :pull:`9078`).
By `Etienne Schalk <https://github.com/etienneschalk>`_.

Performance
~~~~~~~~~~~

Expand Down
6 changes: 3 additions & 3 deletions xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,12 +1457,12 @@ def save_mfdataset(
... coords={"time": pd.date_range("2010-01-01", freq="ME", periods=48)},
... )
>>> ds
<xarray.Dataset> Size: 768B
<xarray.Dataset> 768B
Dimensions: (time: 48)
Coordinates:
* time (time) datetime64[ns] 384B 2010-01-31 2010-02-28 ... 2013-12-31
* time (time) datetime64[ns] 2010-01-31 2010-02-28 ... 2013-12-31
Data variables:
a (time) float64 384B 0.0 0.02128 0.04255 ... 0.9574 0.9787 1.0
a (time) float64 0.0 0.02128 0.04255 ... 0.9574 0.9787 1.0
>>> years, datasets = zip(*ds.groupby("time.year"))
>>> paths = [f"{y}.nc" for y in years]
>>> xr.save_mfdataset(datasets, paths)
Expand Down
12 changes: 6 additions & 6 deletions xarray/coding/cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,30 +383,30 @@ def _partial_date_slice(self, resolution, parsed):
... dims=["time"],
... )
>>> da.sel(time="2001-01-01")
<xarray.DataArray (time: 1)> Size: 8B
<xarray.DataArray (time: 1)> 8B
array([1])
Coordinates:
* time (time) object 8B 2001-01-01 00:00:00
* time (time) object 2001-01-01 00:00:00
>>> da = xr.DataArray(
... [1, 2],
... coords=[[pd.Timestamp(2001, 1, 1), pd.Timestamp(2001, 2, 1)]],
... dims=["time"],
... )
>>> da.sel(time="2001-01-01")
<xarray.DataArray ()> Size: 8B
<xarray.DataArray ()> 8B
array(1)
Coordinates:
time datetime64[ns] 8B 2001-01-01
time datetime64[ns] 2001-01-01
>>> da = xr.DataArray(
... [1, 2],
... coords=[[pd.Timestamp(2001, 1, 1, 1), pd.Timestamp(2001, 2, 1)]],
... dims=["time"],
... )
>>> da.sel(time="2001-01-01")
<xarray.DataArray (time: 1)> Size: 8B
<xarray.DataArray (time: 1)> 8B
array([1])
Coordinates:
* time (time) datetime64[ns] 8B 2001-01-01T01:00:00
* time (time) datetime64[ns] 2001-01-01T01:00:00
"""
start, end = _parsed_string_to_bounds(self.date_type, resolution, parsed)

Expand Down
Loading
Loading