iris icon indicating copy to clipboard operation
iris copied to clipboard

Specific unit testing of `Cube.coord_dims`

Open wjbenfold opened this issue 3 years ago • 6 comments

📰 Custom Issue

Currently there isn't specific unit testing of Cube.coord_dims. I'd like to see this change.

Suggested coverage:

  • coord on the cube
  • coord not on the cube (but matches one that is)
  • coord not on the cube (and doesn't match one that is)
  • string
  • coord on multiple dims
  • coord is aux factory
  • coord is aux_coord

wjbenfold avatar Jan 28 '22 14:01 wjbenfold

The way this currently works, we do have tests for the cube_dims methods of Coord / AncillaryVariable / CellMeasure. (which is essentially the same routine):

  • Coord : https://github.com/SciTools/iris/blob/main/lib/iris/tests/unit/coords/test_Coord.py#L1068
  • CellMeasure : https://github.com/SciTools/iris/blob/main/lib/iris/tests/unit/coords/test_CellMeasure.py#L124
  • AncillaryVariable : https://github.com/SciTools/iris/blob/main/lib/iris/tests/unit/coords/test_AncillaryVariable.py#L691

These are all, actually, basically the same thing, but it is implemented like this because Cube doesn't provide a method to access an arbitrary 'dimensional cube component', equivalent to a _DimensionalMetadata. So we just need to fetch the correct type of object :

I guess the Cube API is done this way, just to make the public Cube API methods explicit, and not too abstract. This also reflects the fact that the cube stores these things apart in separate data structures Ugly though, isn't it ?

pp-mo avatar Jan 31 '22 10:01 pp-mo

Cube doesn't provide a method to access an arbitrary 'dimensional cube component' ... just to make the public Cube API methods explicit ... Ugly though, isn't it ?

Although the unstructured support has now added Connectivity as a subclass of _DimensionalMetadata, and that does not relate to cube dimensions in the same way -- and so, interestingly, its cube_dims method has to be disabled.

pp-mo avatar Jan 31 '22 11:01 pp-mo

Although the unstructured support has now added Connectivity as a subclass of _DimensionalMetadata, and that does not relate to cube dimensions in the same way -- and so, interestingly, its cube_dims method has to be disabled.

This, you may recall, is why @bjlittle has recently mentioned restructuring the inheritance model for _DimensionalMetadata (although if we're going to put in the effort I'd personally quite like to spend the time combining _DimensionalMetadata and Cube into the same inheritance hierarchy).

trexfeathers avatar Jan 31 '22 11:01 trexfeathers

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

github-actions[bot] avatar Nov 04 '23 00:11 github-actions[bot]

This stale issue has been automatically closed due to a lack of community activity.

If you still care about this issue, then please either:

  • Re-open this issue, if you have sufficient permissions, or
  • Add a comment stating that this is still relevant and someone will re-open it on your behalf.

github-actions[bot] avatar Dec 02 '23 00:12 github-actions[bot]