Skip to content

CubeList.copy() should return a CubeList #4066

@trexfeathers

Description

@trexfeathers

✨ Feature Request

As raised by @michaelsanderson42: CubeList.copy() should return a CubeList instead of a list.

Motivation

The unspoken contract of a .copy() method is that it returns a new object of the same type.

Additional context

CubeList is currently inheriting its .copy() behaviour from the list parent class. Docs link

Details
import iris
a = iris.cube.CubeList()
b = a
c = a.copy()
type(a)
# <class 'iris.cube.CubeList'>
type(b)
# <class 'iris.cube.CubeList'>
type(c)
# <class 'list'>
Replication steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueA good issue to take on if you're just getting started with Iris developmentType: Enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions