From 544574cb71be4ad82f2393a5a9b38d31c390b30a Mon Sep 17 00:00:00 2001 From: barronh Date: Mon, 4 Nov 2019 22:00:48 -0500 Subject: [PATCH 1/4] uamiv test using only raw uamiv variables Previous test relied on CF generated metadata, but this test is more robust. --- xarray/tests/test_backends.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 4bdebe73050..bfd53e390d7 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -3400,20 +3400,17 @@ def test_uamiv_format_read(self): actual = camxfile.variables["O3"] assert_allclose(expected, actual) - data = np.array(["2002-06-03"], "datetime64[ns]") + data = np.array([[[2002154, 0]]], dtype='i') expected = xr.Variable( ("TSTEP",), data, dict( - bounds="time_bounds", - long_name=( - "synthesized time coordinate " - + "from SDATE, STIME, STEP " - + "global attributes" - ), + long_name="TFLAG".ljust(16) + var_desc="TFLAG".ljust(80) + units="DATE-TIME".ljust(16) ), ) - actual = camxfile.variables["time"] + actual = camxfile.variables["TFLAG"] assert_allclose(expected, actual) camxfile.close() @@ -3439,18 +3436,14 @@ def test_uamiv_format_mfread(self): actual = camxfile.variables["O3"] assert_allclose(expected, actual) - data1 = np.array(["2002-06-03"], "datetime64[ns]") - data = np.concatenate([data1] * 2, axis=0) + data = np.array([[[2002154, 0]]], dtype='i').repeat(2, 0) attrs = dict( - bounds="time_bounds", - long_name=( - "synthesized time coordinate " - + "from SDATE, STIME, STEP " - + "global attributes" - ), + long_name="TFLAG".ljust(16) + var_desc="TFLAG".ljust(80) + units="DATE-TIME".ljust(16) ) expected = xr.Variable(("TSTEP",), data, attrs) - actual = camxfile.variables["time"] + actual = camxfile.variables["TFLAG"] assert_allclose(expected, actual) camxfile.close() From b1b2070075cbfede876cebd6a434bd23e5801ed3 Mon Sep 17 00:00:00 2001 From: barronh Date: Mon, 4 Nov 2019 22:14:18 -0500 Subject: [PATCH 2/4] uamiv test using only raw uamiv variables Previous test relied on CF generated metadata, but this test is more robust. --- xarray/tests/test_backends.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index bfd53e390d7..a64e0857e5f 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -3405,8 +3405,8 @@ def test_uamiv_format_read(self): ("TSTEP",), data, dict( - long_name="TFLAG".ljust(16) - var_desc="TFLAG".ljust(80) + long_name="TFLAG".ljust(16), + var_desc="TFLAG".ljust(80), units="DATE-TIME".ljust(16) ), ) @@ -3438,8 +3438,8 @@ def test_uamiv_format_mfread(self): data = np.array([[[2002154, 0]]], dtype='i').repeat(2, 0) attrs = dict( - long_name="TFLAG".ljust(16) - var_desc="TFLAG".ljust(80) + long_name="TFLAG".ljust(16), + var_desc="TFLAG".ljust(80), units="DATE-TIME".ljust(16) ) expected = xr.Variable(("TSTEP",), data, attrs) From 31b6f7453124cd589a7e999682f8bb791d0337cd Mon Sep 17 00:00:00 2001 From: barronh Date: Mon, 4 Nov 2019 22:31:41 -0500 Subject: [PATCH 3/4] uamiv test using only raw uamiv variables Previous test relied on CF generated metadata, but this test is more robust. --- xarray/tests/test_backends.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index a64e0857e5f..0dca36e5f81 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -3400,14 +3400,14 @@ def test_uamiv_format_read(self): actual = camxfile.variables["O3"] assert_allclose(expected, actual) - data = np.array([[[2002154, 0]]], dtype='i') + data = np.array([[[2002154, 0]]], dtype="i") expected = xr.Variable( ("TSTEP",), data, dict( long_name="TFLAG".ljust(16), var_desc="TFLAG".ljust(80), - units="DATE-TIME".ljust(16) + units="DATE-TIME".ljust(16), ), ) actual = camxfile.variables["TFLAG"] @@ -3436,11 +3436,11 @@ def test_uamiv_format_mfread(self): actual = camxfile.variables["O3"] assert_allclose(expected, actual) - data = np.array([[[2002154, 0]]], dtype='i').repeat(2, 0) + data = np.array([[[2002154, 0]]], dtype="i").repeat(2, 0) attrs = dict( long_name="TFLAG".ljust(16), var_desc="TFLAG".ljust(80), - units="DATE-TIME".ljust(16) + units="DATE-TIME".ljust(16), ) expected = xr.Variable(("TSTEP",), data, attrs) actual = camxfile.variables["TFLAG"] From ea49dee0f4f8e4e4577c99cb8b96d2992274e3ff Mon Sep 17 00:00:00 2001 From: barronh Date: Tue, 5 Nov 2019 06:39:13 -0500 Subject: [PATCH 4/4] uamiv test using only raw uamiv variables --- xarray/tests/test_backends.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 0dca36e5f81..9b000b82b03 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -3402,7 +3402,7 @@ def test_uamiv_format_read(self): data = np.array([[[2002154, 0]]], dtype="i") expected = xr.Variable( - ("TSTEP",), + ("TSTEP", "VAR", "DATE-TIME"), data, dict( long_name="TFLAG".ljust(16), @@ -3442,7 +3442,8 @@ def test_uamiv_format_mfread(self): var_desc="TFLAG".ljust(80), units="DATE-TIME".ljust(16), ) - expected = xr.Variable(("TSTEP",), data, attrs) + dims = ("TSTEP", "VAR", "DATE-TIME") + expected = xr.Variable(dims, data, attrs) actual = camxfile.variables["TFLAG"] assert_allclose(expected, actual) camxfile.close()