From d6b3c07123d816a0096f8156eea27c047b52ad92 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Wed, 2 Mar 2022 13:47:58 +0000 Subject: [PATCH 1/3] update docs, reinstate test --- cf/data/data.py | 18 +++++++++++++----- cf/test/test_Data.py | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cf/data/data.py b/cf/data/data.py index ffc1c03c65..463001268d 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -8444,21 +8444,29 @@ def clip(self, a_min, a_max, units=None, inplace=False, i=False): return d @classmethod + @daskified(_DASKIFIED_VERBOSE) def asdata(cls, d, dtype=None, copy=False): """Convert the input to a `Data` object. + If the input *d* has the Data interface (i.e. it has a + `__data__` method), then the output of this method is used as + the returned `Data` object. Otherwise, `Data(d)` is returned. + :Parameters: d: data-like - Input data in any form that can be converted to an cf.Data - object. This includes `cf.Data` and `cf.Field` objects, - numpy arrays and any object which may be converted to a + Input data in any form that can be converted to an + `Data` object. This includes `Data` and `Field` + objects, and object with the Data inferface, numpy + arrays and any object which may be converted to a numpy array. dtype: data-type, optional By default, the data-type is inferred from the input data. - copy: + copy: `bool`, optional + If True and *d* has the Data interface, then a copy of + `d.__data__()` is returned. :Returns: @@ -8467,7 +8475,7 @@ def asdata(cls, d, dtype=None, copy=False): input if it is already a `Data` object with matching dtype and *copy* is False. - **Examples:** + **Examples** >>> d = cf.Data([1, 2]) >>> cf.Data.asdata(d) is d diff --git a/cf/test/test_Data.py b/cf/test/test_Data.py index a68ab17555..97a91d27f2 100644 --- a/cf/test/test_Data.py +++ b/cf/test/test_Data.py @@ -1150,7 +1150,6 @@ def test_Data__contains__(self): with self.assertRaises(TypeError): ["foo"] in d - @unittest.skipIf(TEST_DASKIFIED_ONLY, "no attr. 'partition_configuration'") def test_Data_asdata(self): if self.test_only and inspect.stack()[0][3] not in self.test_only: return From f56e350ac62d936d7d8d05ba23453c729a1abc10 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Fri, 4 Mar 2022 08:17:23 +0000 Subject: [PATCH 2/3] Typo Co-authored-by: Sadie L. Bartholomew --- cf/data/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index 463001268d..d9c697a9da 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -8457,7 +8457,7 @@ def asdata(cls, d, dtype=None, copy=False): d: data-like Input data in any form that can be converted to an `Data` object. This includes `Data` and `Field` - objects, and object with the Data inferface, numpy + objects, and objects with the Data interface, numpy arrays and any object which may be converted to a numpy array. From 7b999754601f1b1c028f623a8a2f5f3db83eb949 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Fri, 4 Mar 2022 08:17:37 +0000 Subject: [PATCH 3/3] Typo Co-authored-by: Sadie L. Bartholomew --- cf/data/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index d9c697a9da..923e5cd603 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -8455,7 +8455,7 @@ def asdata(cls, d, dtype=None, copy=False): :Parameters: d: data-like - Input data in any form that can be converted to an + Input data in any form that can be converted to a `Data` object. This includes `Data` and `Field` objects, and objects with the Data interface, numpy arrays and any object which may be converted to a