-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
When running the following example the python interpreter exists abnormally (exit code -1073741819)
The code that causes the exception is the maxnan() function in bottleneck.
This error only occurs when:
- The data contains a dimension with length 1
- The data is transposed
- bottleneck is used
So I suspect that the transpose function changes the data somehow such that bottleneck can not handle it anymore.
- Calling bn.maxnan on a normal ndarray works fine
- Calling data.max() before transposing works fine
- Running the example without using bottleneck (either by not installing it or by disabling it in OPTIONS) works fine
- Running the example with len(time) > 1 works fine
What happened:
Process finished with exit code -1073741819 (0xC0000005)
What you expected to happen:
Script should run without crashing
Minimal Complete Verifiable Example:
from collections import OrderedDict
import numpy as np
import xarray as xr
xr.show_versions()
n_time = 1 # 1 : Fails, 2 : everything is fine
from xarray.core.options import OPTIONS
OPTIONS["use_bottleneck"] = True # Set to False for work-around
# Build some dataset
dirs = np.linspace(0,360, num=121)
freqs = np.linspace(0,4,num=192)
spec_data = np.random.random(size=(n_time,192,121))
dims = ('time', 'freq', 'dir')
coords = OrderedDict()
coords['time'] = range(n_time)
coords['freq'] = freqs
coords['dir'] = dirs
xdata = xr.DataArray(
data=spec_data, coords=coords, dims=dims, name='Spec name',
).to_dataset()
xdata = xdata.transpose(..., "freq") # remove this line and the script will run
tm = xdata.max()
print('Done')
Anything else we need to know?:
Uhm... it was really hard to dig this deep? :-)
Environment:
Tested with python 3.8 and 3.9 on win64. Only required packages are xarray and bottleneck. For example:
name: ws
dependencies:
- python=3.9
- xarray
channels:
- defaults
- conda-forge
note: xarray requires pandas which installs bottleneck. To install without bottleneck pin pandas to 1.2.4
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('English_United States', '1252')
libhdf5: None
libnetcdf: None
xarray: 0.20.1
pandas: 1.2.4
numpy: 1.21.4
scipy: None
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.2
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
setuptools: 59.1.1
pip: 21.3.1
conda: None
pytest: None
IPython: None
sphinx: None