iris
iris copied to clipboard
Specific unit testing of `Cube.coord_dims`
📰 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
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 :
- Coord.cube_dims :
return cube.coord_dims(self) - AncillaryVariable.cube_dims :
return cube.ancillary_variable_dims(self) - CellMeasure.cube_dims :
return cube.cell_measure_dims(self)
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 ?
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.
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_dimsmethod 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).
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.
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.