From 92854dcfd934cf6228cde782e0009c8b9d2e7b95 Mon Sep 17 00:00:00 2001 From: Ruben de Bruin Date: Thu, 18 Nov 2021 14:24:21 +0100 Subject: [PATCH 1/9] Added test for issue #6002 (currently fails) --- xarray/tests/test_transpose.py | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 xarray/tests/test_transpose.py diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py new file mode 100644 index 00000000000..82f229e1ac2 --- /dev/null +++ b/xarray/tests/test_transpose.py @@ -0,0 +1,36 @@ +from collections import OrderedDict +import numpy as np +import xarray as xr +from numpy.testing import assert_allclose + +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) From fc9145a58a7ea93b8d7ff18d33100d138193447c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Nov 2021 13:27:41 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xarray/tests/test_transpose.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index 82f229e1ac2..ebefde2cc56 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -1,15 +1,18 @@ from collections import OrderedDict + import numpy as np -import xarray as xr from numpy.testing import assert_allclose +import xarray as xr + + def test_issue_6002(): - """Ref: https://github.com/pydata/xarray/issues/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 @@ -17,14 +20,17 @@ def test_issue_6002(): freqs = np.linspace(0, 4, num=192) spec_data = np.random.random(size=(n_time, 192, 121)) - dims = ('time', 'freq', 'dir') + dims = ("time", "freq", "dir") coords = OrderedDict() - coords['time'] = range(n_time) - coords['freq'] = freqs - coords['dir'] = dirs + coords["time"] = range(n_time) + coords["freq"] = freqs + coords["dir"] = dirs xdata = xr.DataArray( - data=spec_data, coords=coords, dims=dims, name='Spec name', + data=spec_data, + coords=coords, + dims=dims, + name="Spec name", ).to_dataset() expected = np.max(spec_data) From 116a6d7ad964a8be2b9df0e36e52ea50b5e3376c Mon Sep 17 00:00:00 2001 From: Ruben de Bruin Date: Thu, 18 Nov 2021 14:28:35 +0100 Subject: [PATCH 3/9] Added test for issue #6002 (currently fails) --- xarray/tests/test_transpose.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index 82f229e1ac2..041ff47f75e 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -3,13 +3,14 @@ import xarray as xr from numpy.testing import assert_allclose + def test_issue_6002(): - """Ref: https://github.com/pydata/xarray/issues/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 @@ -17,14 +18,17 @@ def test_issue_6002(): freqs = np.linspace(0, 4, num=192) spec_data = np.random.random(size=(n_time, 192, 121)) - dims = ('time', 'freq', 'dir') + dims = ("time", "freq", "dir") coords = OrderedDict() - coords['time'] = range(n_time) - coords['freq'] = freqs - coords['dir'] = dirs + coords["time"] = range(n_time) + coords["freq"] = freqs + coords["dir"] = dirs xdata = xr.DataArray( - data=spec_data, coords=coords, dims=dims, name='Spec name', + data=spec_data, + coords=coords, + dims=dims, + name="Spec name", ).to_dataset() expected = np.max(spec_data) From 5273a1d9b2bfe6cc2b2e992f669eb5c127a6680b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Nov 2021 13:31:32 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xarray/tests/test_transpose.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index 041ff47f75e..ebefde2cc56 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -1,8 +1,10 @@ from collections import OrderedDict + import numpy as np -import xarray as xr from numpy.testing import assert_allclose +import xarray as xr + def test_issue_6002(): """Ref: https://github.com/pydata/xarray/issues/6002""" From 9a976f859b3eb8533393c5adb5f75eccd5728107 Mon Sep 17 00:00:00 2001 From: Ruben de Bruin Date: Thu, 25 Nov 2021 15:39:30 +0100 Subject: [PATCH 5/9] Added xfail --- xarray/tests/test_transpose.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index ebefde2cc56..9d878085caa 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -1,11 +1,12 @@ from collections import OrderedDict import numpy as np +import pytest from numpy.testing import assert_allclose import xarray as xr - +@pytest.mark.xfail(reason="Bug in bottleneck : bottleneck#393") def test_issue_6002(): """Ref: https://github.com/pydata/xarray/issues/6002""" From cf5485e25281583cf7027c6e1f189e465f28ebfe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:41:27 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xarray/tests/test_transpose.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index 9d878085caa..f1008ea7934 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -6,6 +6,7 @@ import xarray as xr + @pytest.mark.xfail(reason="Bug in bottleneck : bottleneck#393") def test_issue_6002(): """Ref: https://github.com/pydata/xarray/issues/6002""" From 59fa2b1b80438c677a8f116818d2d4ec4b7f0408 Mon Sep 17 00:00:00 2001 From: Ruben de Bruin Date: Mon, 29 Nov 2021 09:50:48 +0100 Subject: [PATCH 7/9] removed xfail --- xarray/tests/test_transpose.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index 9d878085caa..db93d78fbef 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -6,7 +6,6 @@ import xarray as xr -@pytest.mark.xfail(reason="Bug in bottleneck : bottleneck#393") def test_issue_6002(): """Ref: https://github.com/pydata/xarray/issues/6002""" From 403bcd652bc633670422c0e3c32b683a99fc3af6 Mon Sep 17 00:00:00 2001 From: Ruben de Bruin Date: Mon, 29 Nov 2021 09:51:29 +0100 Subject: [PATCH 8/9] removed xfail --- xarray/tests/test_transpose.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index f1008ea7934..db93d78fbef 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -6,8 +6,6 @@ import xarray as xr - -@pytest.mark.xfail(reason="Bug in bottleneck : bottleneck#393") def test_issue_6002(): """Ref: https://github.com/pydata/xarray/issues/6002""" From e73c3f80319cd1b2ea7f93133fdf15fe0458787f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Nov 2021 08:53:23 +0000 Subject: [PATCH 9/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xarray/tests/test_transpose.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xarray/tests/test_transpose.py b/xarray/tests/test_transpose.py index db93d78fbef..d8edd2cb3cc 100644 --- a/xarray/tests/test_transpose.py +++ b/xarray/tests/test_transpose.py @@ -6,6 +6,7 @@ import xarray as xr + def test_issue_6002(): """Ref: https://github.com/pydata/xarray/issues/6002"""