Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CubeList instantiation #4079

Closed
rcomer opened this issue Mar 29, 2021 · 1 comment · Fixed by #4767
Closed

CubeList instantiation #4079

rcomer opened this issue Mar 29, 2021 · 1 comment · Fixed by #4767

Comments

@rcomer
Copy link
Member

rcomer commented Mar 29, 2021

📚 Documentation

I was reviewing a code change and saw something like

cubelist = iris.cube.CubeList(list(dictionary_of_cubes.values()))

list has been inserted by 2to3, and I initially thought "that's redundant". But then I looked at the docs, and it does specifically say "Given a list of cubes, return a CubeList instance." Is this intentional? So far, every sequence type I've tried appears to work at Iris3.0.1:

cube1 = iris.cube.Cube(1, long_name='foo')
cube2 = iris.cube.Cube(1, long_name='bar')

def generate_cubes():
    yield cube2
    yield cube1

cubedict = dict(foo=cube1, bar=cube2)

cubelist1 = iris.cube.CubeList((cube1, cube2))
cubelist2 = iris.cube.CubeList(generate_cubes())
cubelist3 = iris.cube.CubeList(cubedict.values())
@rcomer
Copy link
Member Author

rcomer commented Mar 29, 2021

On closer inspection, I realise I am reading the docstring of the __new__ method, which we’ve already decided shouldn’t be there. #3264 specifies an iterable of cubes in the __init__ docstring, so that would answer my question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant