From 00277cd5a7851ec272558b6d7b7a038b6b0c294a Mon Sep 17 00:00:00 2001 From: David Hassell Date: Wed, 6 Apr 2022 14:13:14 +0100 Subject: [PATCH 1/2] data --- cf/data/data.py | 4 +++- cf/functions.py | 3 +-- cf/test/test_Data.py | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cf/data/data.py b/cf/data/data.py index f9c2d3bb50..dc57a279fc 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -5988,11 +5988,13 @@ def Units(self): ) @property + @daskified(_DASKIFIED_VERBOSE) def data(self): """The data as an object identity. - **Examples:** + **Examples** + >>> d = cf.Data([1, 2], 'm') >>> d.data is d True diff --git a/cf/functions.py b/cf/functions.py index ebb12c20fa..4c8355a38f 100644 --- a/cf/functions.py +++ b/cf/functions.py @@ -13,7 +13,6 @@ from collections.abc import Iterable from itertools import product from marshal import dumps -from math import ceil as math_ceil from numbers import Integral from os import getpid, listdir, mkdir from os.path import abspath as _os_path_abspath @@ -25,9 +24,9 @@ import cfdm import netCDF4 +import numpy as np from dask import config from dask.utils import parse_bytes -import numpy as np from numpy import __file__ as _numpy__file__ from numpy import __version__ as _numpy__version__ from numpy import all as _numpy_all diff --git a/cf/test/test_Data.py b/cf/test/test_Data.py index 9e6a610ab8..74e9c44697 100644 --- a/cf/test/test_Data.py +++ b/cf/test/test_Data.py @@ -3938,6 +3938,10 @@ def test_Data_tolist(self): self.assertEqual(e, np.array(x).tolist()) self.assertTrue(d.equals(cf.Data(e))) + def test_Data_data(self): + d = cf.Data([1, 2], "m") + self.assertIs(d.data, d) + if __name__ == "__main__": print("Run date:", datetime.datetime.now()) From ff7e3767b34e3521b9d0f135e70679a3243f8a9c Mon Sep 17 00:00:00 2001 From: David Hassell Date: Tue, 12 Apr 2022 10:43:57 +0100 Subject: [PATCH 2/2] More rigorous Data.data tests Co-authored-by: Sadie L. Bartholomew --- cf/test/test_Data.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cf/test/test_Data.py b/cf/test/test_Data.py index 74e9c44697..484cc32bf2 100644 --- a/cf/test/test_Data.py +++ b/cf/test/test_Data.py @@ -3939,8 +3939,14 @@ def test_Data_tolist(self): self.assertTrue(d.equals(cf.Data(e))) def test_Data_data(self): - d = cf.Data([1, 2], "m") - self.assertIs(d.data, d) + for d in [ + cf.Data(1), + cf.Data([1, 2], fill_value=0), + cf.Data([1, 2], "m"), + cf.Data([1, 2], mask=[1,0], units="m"), + cf.Data([[0, 1, 2], [3, 4, 5]], chunks=2), + ]: + self.assertIs(d.data, d) if __name__ == "__main__":