Description
In [15]: xr.DataArray(np.random.randint(2,size=(100,100)).astype(bool)).shift(dim_0=0)
Out[15]:
<xarray.DataArray (dim_0: 100, dim_1: 100)>
array([[False, True, True, ..., True, True, False],
[False, True, False, ..., False, True, True],
[False, True, False, ..., False, True, False],
...,
[False, True, False, ..., False, True, True],
[True, False, True, ..., False, False, False],
[False, True, True, ..., True, True, False]], dtype=object) # <-- could be bool
Dimensions without coordinates: dim_0, dim_1
Problem description
This causes memory bloat
Expected Output
As above with dtype=bool
Output of xr.show_versions()
In [16]: xr.show_versions()
INSTALLED VERSIONS
commit: f9c4169
python: 2.7.15.final.0
python-bits: 64
OS: Darwin
OS-release: 18.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
xarray: 0.10.9+12.gf9c41691
pandas: 0.22.0
numpy: 1.14.2
scipy: 1.0.0
netCDF4: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
PseudonetCDF: None
rasterio: None
iris: None
bottleneck: 1.2.1
cyordereddict: None
dask: None
distributed: None
matplotlib: 2.1.2
cartopy: None
seaborn: 0.8.1
setuptools: 39.2.0
pip: 18.0
conda: None
pytest: 3.6.3
IPython: 5.8.0
sphinx: None
The shift=0
is mainly theoretical. To avoid casting to object
in practical scenarios, we could add a fill_value
argument (e.g. fill_value=False
) and fill with that rather than NaN
CC @IvoCrnkovic