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

Added test for issue #6002 (currently fails) #6003

Closed
wants to merge 11 commits into from
43 changes: 43 additions & 0 deletions xarray/tests/test_transpose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from collections import OrderedDict

import numpy as np
import pytest
from numpy.testing import assert_allclose

import xarray as xr


def test_issue_6002():
"""Ref: https://github.com/pydata/xarray/issues/6002"""

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()

expected = np.max(spec_data)

xdata = xdata.transpose(..., "freq") # remove this line and the script will run

tm = xdata.max()

assert_allclose(tm, expected)