From 975002049569257a0c110b2a0ecdf74fa4072bbb Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Mon, 1 Aug 2022 23:47:24 +0100 Subject: [PATCH 1/2] Deprecate 'concatenate_data' (essentially same as 'concatenate') --- cf/data/data.py | 31 ------------------------------- cf/data/mixin/deprecations.py | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/cf/data/data.py b/cf/data/data.py index c9445a02d7..ed050cca01 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -5640,37 +5640,6 @@ def apply_masking( return d - @classmethod - def concatenate_data(cls, data_list, axis): - """Concatenates a list of Data objects into a single Data object - along the specified access (see cf.Data.concatenate for - details). In the case that the list contains only one element, - that element is simply returned. - - :Parameters: - - data_list: `list` - The list of data objects to concatenate. - - axis: `int` - The axis along which to perform the concatenation. - - :Returns: - - `Data` - The resulting single `Data` object. - - """ - if len(data_list) > 1: - data = cls.concatenate(data_list, axis=axis) - if data.fits_in_one_chunk_in_memory(data.dtype.itemsize): - data.varray - - return data - else: - assert len(data_list) == 1 - return data_list[0] - def argmax(self, axis=None, unravel=False): """Return the indices of the maximum values along an axis. diff --git a/cf/data/mixin/deprecations.py b/cf/data/mixin/deprecations.py index 4b3f078dee..57c32cfe17 100644 --- a/cf/data/mixin/deprecations.py +++ b/cf/data/mixin/deprecations.py @@ -966,3 +966,30 @@ def reconstruct_sectioned_data(cls, sections, cyclic=(), hardmask=None): "Data method 'reconstruct_sectioned_data' has been deprecated " "at version TODODASK and is no longer available" ) + + @classmethod + def concatenate_data(cls, data_list, axis): + """Concatenates a list of Data objects into a single Data object + along the specified access (see cf.Data.concatenate for + details). In the case that the list contains only one element, + that element is simply returned. + + :Parameters: + + data_list: `list` + The list of data objects to concatenate. + + axis: `int` + The axis along which to perform the concatenation. + + :Returns: + + `Data` + The resulting single `Data` object. + + """ + raise DeprecationError( + "Data method 'concatenate_data' has been deprecated at " + "version TODODASK and is no longer available. Use " + "'concatenate' instead." + ) From b36757843eb9a77fd095b9aaae452b38087f27ee Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Mon, 1 Aug 2022 23:58:19 +0100 Subject: [PATCH 2/2] Format and fix typo in docstring for 'concatenate_data' --- cf/data/mixin/deprecations.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cf/data/mixin/deprecations.py b/cf/data/mixin/deprecations.py index 57c32cfe17..a4f9cabda6 100644 --- a/cf/data/mixin/deprecations.py +++ b/cf/data/mixin/deprecations.py @@ -969,10 +969,12 @@ def reconstruct_sectioned_data(cls, sections, cyclic=(), hardmask=None): @classmethod def concatenate_data(cls, data_list, axis): - """Concatenates a list of Data objects into a single Data object - along the specified access (see cf.Data.concatenate for - details). In the case that the list contains only one element, - that element is simply returned. + """Concatenates a list of Data objects along the specified axis. + + See cf.Data.concatenate for details. + + In the case that the list contains only one element, that element + is simply returned. :Parameters: