Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ This document explains the changes made to Iris for this release
printing these objects skips metadata elements that are set to None or an
empty string or dictionary. (:pull:`4040`)

#. `@Badboy-16`_ implemented a ``CubeList.copy()`` method to return a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link also needs creating toward the bottom of the file - currently L172-174.

That will fix the test failures.

``CubeList`` object instead of a ``list``. (:pull:`4094`)


🐛 Bugs Fixed
=============
Expand Down Expand Up @@ -189,4 +192,4 @@ This document explains the changes made to Iris for this release
.. _Python 3.8: https://www.python.org/downloads/release/python-380/
.. _README.md: https://github.com/SciTools/iris#-----
.. _xxhash: http://cyan4973.github.io/xxHash/
.. _conda-lock: https://github.com/conda-incubator/conda-lock
.. _conda-lock: https://github.com/conda-incubator/conda-lock
7 changes: 7 additions & 0 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@ def realise_data(self):
"""
_lazy.co_realise_cubes(*self)

def copy(self):
"""
Return a CubeList when CubeList.copy() is called.
"""
if type(self) == CubeList:
return deepcopy(self)


def _is_single_item(testee):
"""
Expand Down
9 changes: 9 additions & 0 deletions lib/iris/tests/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,14 @@ class Terry:
self.assertIs(cube.__ne__(Terry()), NotImplemented)


class Test_CubeList_copy(tests.IrisTest):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This belongs in tests/unit/cube/test_CubeList.py

I fully acknowledge Iris' testing structure is unclear!

def setUp(self):
self.cube_list = iris.cube.CubeList()
self.copied_cube_list = self.cube_list.copy()

def test_copy(self):
self.assertIsInstance(self.copied_cube_list, iris.cube.CubeList)


if __name__ == "__main__":
tests.main()