Skip to content

Conversation

@ESadek-MO
Copy link
Contributor

🚀 Pull Request

Closes #3916.

Added dim coord prioritisation to _get_lon_lat_coords() in iris.analysis.cartography. This allows iris.analysis.cartography.area_weights() and iris.analysis.cartography.project() to handle cubes which contain both dim and aux coords of the same type e.g. longitude and grid_longitude.

Copy link
Contributor

@stephenworsley stephenworsley left a comment

Choose a reason for hiding this comment

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

This looks good.
My comments here are mostly about the style of the tests. These seem to be more in line with pytest, which we have relatively recently adopted, so I'm not against a stylistic change in principle. If there is an example in our code of tests in this style I would be interested in comparing it. Though if this is setting a precedent then I think it might want a broader discussion about what precedents we want to set before departing from our existing style.

The existing style, as far as I'm aware, involves nesting test functions in classes and having all code executed either within the test function or within setup and teardown methods.

@trexfeathers
Copy link
Contributor

@PaytonLeedham is going to give this a once over since we're all still getting used to pytest!

Copy link
Contributor

@stephenworsley stephenworsley left a comment

Choose a reason for hiding this comment

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

Looks good, just one minor point on the use of yield vs return. As far as I'm aware, using yield causes pytest to use a little extra machinery to remember and run the rest of the code in these fixtures. I'm not sure of all the details of how pytest deals with yield with no code afterwards vs how it deals with return, but it seems like using return is the simpler case and therefore better practice to use when yield is not necessary. This seems to be the pattern in the pytest documentation.

@stephenworsley
Copy link
Contributor

One more thought, it might be worth adding a note here to say which type of coordinate you are prioritising:

Something like:

If there are both 1 and 2 dimensional latitude-longitude coordinates, only
the 1 dimensional coordinates will be used.

Copy link
Contributor

@stephenworsley stephenworsley left a comment

Choose a reason for hiding this comment

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

Looks good!

@stephenworsley stephenworsley merged commit b5178a9 into SciTools:main Oct 27, 2022
@ESadek-MO ESadek-MO deleted the prioritise_dim_coord branch November 23, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't get area weights of cube with additional auxillary coordinates of lat and lon

3 participants